├── vendor ├── github.com │ ├── spf13 │ │ ├── cobra │ │ │ ├── command_notwin.go │ │ │ └── command_win.go │ │ └── pflag │ │ │ ├── LICENSE │ │ │ └── int.go │ ├── docker │ │ ├── docker │ │ │ ├── client │ │ │ │ ├── client_windows.go │ │ │ │ ├── client_unix.go │ │ │ │ ├── interface_stable.go │ │ │ │ ├── secret_remove.go │ │ │ │ ├── service_remove.go │ │ │ │ ├── network_remove.go │ │ │ │ ├── plugin_set.go │ │ │ │ ├── swarm_join.go │ │ │ │ ├── container_unpause.go │ │ │ │ ├── container_pause.go │ │ │ │ ├── swarm_leave.go │ │ │ │ ├── swarm_unlock.go │ │ │ │ ├── container_rename.go │ │ │ │ ├── checkpoint_create.go │ │ │ │ ├── plugin_push.go │ │ │ │ ├── node_remove.go │ │ │ │ ├── plugin_remove.go │ │ │ │ ├── container_kill.go │ │ │ │ ├── plugin_disable.go │ │ │ │ ├── plugin_enable.go │ │ │ │ ├── network_disconnect.go │ │ │ │ ├── node_update.go │ │ │ │ ├── swarm_inspect.go │ │ │ │ ├── plugin_list.go │ │ │ │ ├── container_export.go │ │ │ │ ├── swarm_init.go │ │ │ │ ├── image_save.go │ │ │ │ ├── version.go │ │ │ │ ├── volume_remove.go │ │ │ │ ├── secret_update.go │ │ │ │ ├── network_connect.go │ │ │ │ ├── swarm_get_unlock_key.go │ │ │ │ ├── checkpoint_delete.go │ │ │ │ ├── image_history.go │ │ │ │ ├── volume_create.go │ │ │ │ ├── interface_experimental.go │ │ │ │ ├── info.go │ │ │ │ ├── disk_usage.go │ │ │ │ ├── container_diff.go │ │ │ │ ├── container_stop.go │ │ │ │ ├── secret_create.go │ │ │ │ ├── container_remove.go │ │ │ │ ├── plugin_create.go │ │ │ │ ├── container_update.go │ │ │ │ ├── container_start.go │ │ │ │ ├── transport.go │ │ │ │ ├── container_restart.go │ │ │ │ ├── container_wait.go │ │ │ │ ├── network_create.go │ │ │ │ ├── image_remove.go │ │ │ │ ├── swarm_update.go │ │ │ │ ├── container_stats.go │ │ │ │ ├── container_top.go │ │ │ │ ├── ping.go │ │ │ │ ├── checkpoint_list.go │ │ │ │ ├── plugin_inspect.go │ │ │ │ ├── task_list.go │ │ │ │ ├── node_list.go │ │ │ │ ├── service_create.go │ │ │ │ ├── utils.go │ │ │ │ ├── image_load.go │ │ │ │ ├── secret_list.go │ │ │ │ ├── service_list.go │ │ │ │ ├── volume_list.go │ │ │ │ ├── login.go │ │ │ │ ├── node_inspect.go │ │ │ │ ├── secret_inspect.go │ │ │ │ ├── network_list.go │ │ │ │ ├── task_inspect.go │ │ │ │ ├── service_inspect.go │ │ │ │ ├── image_inspect.go │ │ │ │ ├── image_prune.go │ │ │ │ ├── volume_prune.go │ │ │ │ ├── container_prune.go │ │ │ │ ├── network_prune.go │ │ │ │ ├── container_resize.go │ │ │ │ ├── image_import.go │ │ │ │ ├── image_create.go │ │ │ │ ├── container_attach.go │ │ │ │ ├── image_tag.go │ │ │ │ ├── service_update.go │ │ │ │ ├── volume_inspect.go │ │ │ │ ├── service_logs.go │ │ │ │ ├── container_logs.go │ │ │ │ ├── container_list.go │ │ │ │ ├── network_inspect.go │ │ │ │ ├── image_list.go │ │ │ │ ├── image_pull.go │ │ │ │ ├── container_commit.go │ │ │ │ ├── image_search.go │ │ │ │ ├── container_inspect.go │ │ │ │ ├── image_push.go │ │ │ │ ├── container_create.go │ │ │ │ ├── container_exec.go │ │ │ │ └── events.go │ │ │ ├── pkg │ │ │ │ └── tlsconfig │ │ │ │ │ ├── tlsconfig_clone.go │ │ │ │ │ ├── tlsconfig_clone_go16.go │ │ │ │ │ └── tlsconfig_clone_go17.go │ │ │ ├── api │ │ │ │ └── types │ │ │ │ │ ├── time │ │ │ │ │ └── duration_convert.go │ │ │ │ │ ├── error_response.go │ │ │ │ │ ├── id_response.go │ │ │ │ │ ├── service_update_response.go │ │ │ │ │ ├── blkiodev │ │ │ │ │ └── blkio.go │ │ │ │ │ ├── plugin_interface_type.go │ │ │ │ │ ├── container │ │ │ │ │ ├── container_update.go │ │ │ │ │ ├── container_wait.go │ │ │ │ │ ├── container_create.go │ │ │ │ │ ├── hostconfig_unix.go │ │ │ │ │ └── hostconfig_windows.go │ │ │ │ │ ├── port.go │ │ │ │ │ ├── plugin_env.go │ │ │ │ │ ├── plugin_device.go │ │ │ │ │ ├── swarm │ │ │ │ │ ├── secret.go │ │ │ │ │ ├── common.go │ │ │ │ │ └── container.go │ │ │ │ │ ├── registry │ │ │ │ │ └── authenticate.go │ │ │ │ │ ├── volume │ │ │ │ │ ├── volumes_list.go │ │ │ │ │ └── volumes_create.go │ │ │ │ │ ├── auth.go │ │ │ │ │ ├── plugin_mount.go │ │ │ │ │ ├── strslice │ │ │ │ │ └── strslice.go │ │ │ │ │ ├── reference │ │ │ │ │ └── image_reference.go │ │ │ │ │ ├── image_summary.go │ │ │ │ │ ├── events │ │ │ │ │ └── events.go │ │ │ │ │ ├── versions │ │ │ │ │ └── compare.go │ │ │ │ │ ├── plugin_responses.go │ │ │ │ │ ├── volume.go │ │ │ │ │ ├── network │ │ │ │ │ └── network.go │ │ │ │ │ └── configs.go │ │ │ └── NOTICE │ │ ├── distribution │ │ │ ├── reference │ │ │ │ ├── helpers.go │ │ │ │ └── normalize.go │ │ │ └── digest │ │ │ │ ├── digester.go │ │ │ │ ├── verifiers.go │ │ │ │ └── doc.go │ │ ├── go-connections │ │ │ ├── tlsconfig │ │ │ │ ├── certpool_other.go │ │ │ │ ├── config_legacy_client_ciphers.go │ │ │ │ ├── config_client_ciphers.go │ │ │ │ └── certpool_go17.go │ │ │ ├── sockets │ │ │ │ ├── tcp_socket.go │ │ │ │ ├── unix_socket.go │ │ │ │ ├── sockets_windows.go │ │ │ │ ├── sockets_unix.go │ │ │ │ ├── sockets.go │ │ │ │ ├── proxy.go │ │ │ │ └── inmem_socket.go │ │ │ └── nat │ │ │ │ ├── parse.go │ │ │ │ └── sort.go │ │ └── go-units │ │ │ └── duration.go │ ├── Sirupsen │ │ └── logrus │ │ │ ├── terminal_appengine.go │ │ │ ├── terminal_bsd.go │ │ │ ├── terminal_solaris.go │ │ │ ├── terminal_linux.go │ │ │ ├── doc.go │ │ │ ├── terminal_notwindows.go │ │ │ ├── terminal_windows.go │ │ │ ├── LICENSE │ │ │ ├── hooks.go │ │ │ ├── writer.go │ │ │ ├── formatter.go │ │ │ ├── json_formatter.go │ │ │ └── alt_exit.go │ ├── dustin │ │ └── go-humanize │ │ │ ├── humanize.go │ │ │ ├── ordinals.go │ │ │ ├── ftoa.go │ │ │ ├── big.go │ │ │ ├── commaf.go │ │ │ ├── LICENSE │ │ │ ├── comma.go │ │ │ └── si.go │ ├── opencontainers │ │ └── go-digest │ │ │ ├── digester.go │ │ │ ├── verifiers.go │ │ │ └── doc.go │ └── pkg │ │ └── errors │ │ └── LICENSE └── golang.org │ └── x │ ├── crypto │ ├── ssh │ │ └── terminal │ │ │ ├── util_bsd.go │ │ │ ├── util_linux.go │ │ │ ├── util_solaris.go │ │ │ └── util_plan9.go │ ├── PATENTS │ └── LICENSE │ └── net │ ├── proxy │ ├── direct.go │ └── proxy.go │ ├── PATENTS │ ├── LICENSE │ └── context │ ├── ctxhttp │ └── ctxhttp.go │ └── go17.go ├── Dockerfile ├── Makefile ├── cmd └── buildcache │ ├── main.go │ └── save.go ├── vendor.conf └── README.md /vendor/github.com/spf13/cobra/command_notwin.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package cobra 4 | 5 | var preExecHookFn func(*Command) 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.7-alpine 2 | RUN apk add --no-cache git 3 | RUN go get --v github.com/tonistiigi/buildcache/cmd/buildcache 4 | ENTRYPOINT ["/go/bin/buildcache"] 5 | CMD ["save", "-h"] 6 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/client_windows.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | // DefaultDockerHost defines os specific default if DOCKER_HOST is unset 4 | const DefaultDockerHost = "npipe:////./pipe/docker_engine" 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | binary: 2 | go build ./cmd/buildcache 3 | 4 | install: binary 5 | cp ./buildcache /usr/bin 6 | 7 | fmt: 8 | go fmt ./... 9 | 10 | vendor: vendor.conf 11 | vndr 12 | 13 | .PHONY: 14 | vendor binary install fmt -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package logrus 4 | 5 | // IsTerminal returns true if stderr's file descriptor is a terminal. 6 | func IsTerminal() bool { 7 | return true 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/client_unix.go: -------------------------------------------------------------------------------- 1 | // +build linux freebsd solaris openbsd darwin 2 | 3 | package client 4 | 5 | // DefaultDockerHost defines os specific default if DOCKER_HOST is unset 6 | const DefaultDockerHost = "unix:///var/run/docker.sock" 7 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package logrus 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | 10 | type Termios syscall.Termios 11 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/humanize.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package humanize converts boring ugly numbers to human-friendly strings and back. 3 | 4 | Durations can be turned into strings such as "3 days ago", numbers 5 | representing sizes like 82854982 into useful strings like, "83MB" or 6 | "79MiB" (whichever you prefer). 7 | */ 8 | package humanize 9 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/reference/helpers.go: -------------------------------------------------------------------------------- 1 | package reference 2 | 3 | // IsNameOnly returns true if reference only contains a repo name. 4 | func IsNameOnly(ref Named) bool { 5 | if _, ok := ref.(NamedTagged); ok { 6 | return false 7 | } 8 | if _, ok := ref.(Canonical); ok { 9 | return false 10 | } 11 | return true 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/interface_stable.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | // APIClient is an interface that clients that talk with a docker server must implement. 4 | type APIClient interface { 5 | CommonAPIClient 6 | apiClientExperimental 7 | } 8 | 9 | // Ensure that Client always implements APIClient. 10 | var _ APIClient = &Client{} 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/secret_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // SecretRemove removes a Secret. 6 | func (cli *Client) SecretRemove(ctx context.Context, id string) error { 7 | resp, err := cli.delete(ctx, "/secrets/"+id, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package tlsconfig 4 | 5 | import "crypto/tls" 6 | 7 | // Clone returns a clone of tls.Config. This function is provided for 8 | // compatibility for go1.7 that doesn't include this method in stdlib. 9 | func Clone(c *tls.Config) *tls.Config { 10 | return c.Clone() 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/service_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // ServiceRemove kills and removes a service. 6 | func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error { 7 | resp, err := cli.delete(ctx, "/services/"+serviceID, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris,!appengine 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // NetworkRemove removes an existent network from the docker host. 6 | func (cli *Client) NetworkRemove(ctx context.Context, networkID string) error { 7 | resp, err := cli.delete(ctx, "/networks/"+networkID, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/time/duration_convert.go: -------------------------------------------------------------------------------- 1 | package time 2 | 3 | import ( 4 | "strconv" 5 | "time" 6 | ) 7 | 8 | // DurationToSecondsString converts the specified duration to the number 9 | // seconds it represents, formatted as a string. 10 | func DurationToSecondsString(duration time.Duration) string { 11 | return strconv.FormatFloat(duration.Seconds(), 'f', 0, 64) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_set.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "golang.org/x/net/context" 5 | ) 6 | 7 | // PluginSet modifies settings for an existing plugin 8 | func (cli *Client) PluginSet(ctx context.Context, name string, args []string) error { 9 | resp, err := cli.post(ctx, "/plugins/"+name+"/set", nil, args, nil) 10 | ensureReaderClosed(resp) 11 | return err 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_join.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types/swarm" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | // SwarmJoin joins the swarm. 9 | func (cli *Client) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error { 10 | resp, err := cli.post(ctx, "/swarm/join", nil, req, nil) 11 | ensureReaderClosed(resp) 12 | return err 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !appengine 7 | 8 | package logrus 9 | 10 | import "syscall" 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | type Termios syscall.Termios 15 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_unpause.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // ContainerUnpause resumes the process execution within a container 6 | func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error { 7 | resp, err := cli.post(ctx, "/containers/"+containerID+"/unpause", nil, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/error_response.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // ErrorResponse Represents an error. 7 | // swagger:model ErrorResponse 8 | type ErrorResponse struct { 9 | 10 | // The error message. 11 | // Required: true 12 | Message string `json:"message"` 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_pause.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // ContainerPause pauses the main process of a given container without terminating it. 6 | func (cli *Client) ContainerPause(ctx context.Context, containerID string) error { 7 | resp, err := cli.post(ctx, "/containers/"+containerID+"/pause", nil, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/id_response.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // IDResponse Response to an API call that returns just an Id 7 | // swagger:model IdResponse 8 | type IDResponse struct { 9 | 10 | // The id of the newly created object. 11 | // Required: true 12 | ID string `json:"Id"` 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/service_update_response.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // ServiceUpdateResponse service update response 7 | // swagger:model ServiceUpdateResponse 8 | type ServiceUpdateResponse struct { 9 | 10 | // Optional warning messages 11 | Warnings []string `json:"Warnings"` 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_leave.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // SwarmLeave leaves the swarm. 10 | func (cli *Client) SwarmLeave(ctx context.Context, force bool) error { 11 | query := url.Values{} 12 | if force { 13 | query.Set("force", "1") 14 | } 15 | resp, err := cli.post(ctx, "/swarm/leave", query, nil, nil) 16 | ensureReaderClosed(resp) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_unlock.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types/swarm" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | // SwarmUnlock unlockes locked swarm. 9 | func (cli *Client) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error { 10 | serverResp, err := cli.post(ctx, "/swarm/unlock", nil, req, nil) 11 | if err != nil { 12 | return err 13 | } 14 | 15 | ensureReaderClosed(serverResp) 16 | return err 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/tlsconfig/certpool_other.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package tlsconfig 4 | 5 | import ( 6 | "crypto/x509" 7 | 8 | "github.com/Sirupsen/logrus" 9 | ) 10 | 11 | // SystemCertPool returns an new empty cert pool, 12 | // accessing system cert pool is supported in go 1.7 13 | func SystemCertPool() (*x509.CertPool, error) { 14 | logrus.Warn("Unable to use system certificate pool: requires building with go 1.7 or later") 15 | return x509.NewCertPool(), nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/proxy/direct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proxy 6 | 7 | import ( 8 | "net" 9 | ) 10 | 11 | type direct struct{} 12 | 13 | // Direct is a direct proxy: one that makes network connections directly. 14 | var Direct = direct{} 15 | 16 | func (direct) Dial(network, addr string) (net.Conn, error) { 17 | return net.Dial(network, addr) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/tlsconfig/config_legacy_client_ciphers.go: -------------------------------------------------------------------------------- 1 | // +build !go1.5 2 | 3 | // Package tlsconfig provides primitives to retrieve secure-enough TLS configurations for both clients and servers. 4 | // 5 | package tlsconfig 6 | 7 | import ( 8 | "crypto/tls" 9 | ) 10 | 11 | // Client TLS cipher suites (dropping CBC ciphers for client preferred suite set) 12 | var clientCipherSuites = []uint16{ 13 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 14 | tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ordinals.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | // Ordinal gives you the input number in a rank/ordinal format. 6 | // 7 | // Ordinal(3) -> 3rd 8 | func Ordinal(x int) string { 9 | suffix := "th" 10 | switch x % 10 { 11 | case 1: 12 | if x%100 != 11 { 13 | suffix = "st" 14 | } 15 | case 2: 16 | if x%100 != 12 { 17 | suffix = "nd" 18 | } 19 | case 3: 20 | if x%100 != 13 { 21 | suffix = "rd" 22 | } 23 | } 24 | return strconv.Itoa(x) + suffix 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_rename.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // ContainerRename changes the name of a given container. 10 | func (cli *Client) ContainerRename(ctx context.Context, containerID, newContainerName string) error { 11 | query := url.Values{} 12 | query.Set("name", newContainerName) 13 | resp, err := cli.post(ctx, "/containers/"+containerID+"/rename", query, nil, nil) 14 | ensureReaderClosed(resp) 15 | return err 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/checkpoint_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | // CheckpointCreate creates a checkpoint from the given container with the given name 9 | func (cli *Client) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error { 10 | resp, err := cli.post(ctx, "/containers/"+container+"/checkpoints", nil, options, nil) 11 | ensureReaderClosed(resp) 12 | return err 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_push.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // PluginPush pushes a plugin to a registry 10 | func (cli *Client) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) { 11 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 12 | resp, err := cli.post(ctx, "/plugins/"+name+"/push", nil, nil, headers) 13 | if err != nil { 14 | return nil, err 15 | } 16 | return resp.body, nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ftoa.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | func stripTrailingZeros(s string) string { 6 | offset := len(s) - 1 7 | for offset > 0 { 8 | if s[offset] == '.' { 9 | offset-- 10 | break 11 | } 12 | if s[offset] != '0' { 13 | break 14 | } 15 | offset-- 16 | } 17 | return s[:offset+1] 18 | } 19 | 20 | // Ftoa converts a float to a string with no trailing zeros. 21 | func Ftoa(num float64) string { 22 | return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/node_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // NodeRemove removes a Node. 12 | func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error { 13 | query := url.Values{} 14 | if options.Force { 15 | query.Set("force", "1") 16 | } 17 | 18 | resp, err := cli.delete(ctx, "/nodes/"+nodeID, query, nil) 19 | ensureReaderClosed(resp) 20 | return err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // PluginRemove removes a plugin 11 | func (cli *Client) PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error { 12 | query := url.Values{} 13 | if options.Force { 14 | query.Set("force", "1") 15 | } 16 | 17 | resp, err := cli.delete(ctx, "/plugins/"+name, query, nil) 18 | ensureReaderClosed(resp) 19 | return err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_kill.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // ContainerKill terminates the container process but does not remove the container from the docker host. 10 | func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error { 11 | query := url.Values{} 12 | query.Set("signal", signal) 13 | 14 | resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil) 15 | ensureReaderClosed(resp) 16 | return err 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_disable.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // PluginDisable disables a plugin 11 | func (cli *Client) PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error { 12 | query := url.Values{} 13 | if options.Force { 14 | query.Set("force", "1") 15 | } 16 | resp, err := cli.post(ctx, "/plugins/"+name+"/disable", query, nil, nil) 17 | ensureReaderClosed(resp) 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_enable.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // PluginEnable enables a plugin 12 | func (cli *Client) PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error { 13 | query := url.Values{} 14 | query.Set("timeout", strconv.Itoa(options.Timeout)) 15 | 16 | resp, err := cli.post(ctx, "/plugins/"+name+"/enable", query, nil, nil) 17 | ensureReaderClosed(resp) 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_disconnect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | // NetworkDisconnect disconnects a container from an existent network in the docker host. 9 | func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error { 10 | nd := types.NetworkDisconnect{Container: containerID, Force: force} 11 | resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) 12 | ensureReaderClosed(resp) 13 | return err 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/node_update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "github.com/docker/docker/api/types/swarm" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // NodeUpdate updates a Node. 12 | func (cli *Client) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error { 13 | query := url.Values{} 14 | query.Set("version", strconv.FormatUint(version.Index, 10)) 15 | resp, err := cli.post(ctx, "/nodes/"+nodeID+"/update", query, node, nil) 16 | ensureReaderClosed(resp) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types/swarm" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // SwarmInspect inspects the swarm. 11 | func (cli *Client) SwarmInspect(ctx context.Context) (swarm.Swarm, error) { 12 | serverResp, err := cli.get(ctx, "/swarm", nil, nil) 13 | if err != nil { 14 | return swarm.Swarm{}, err 15 | } 16 | 17 | var response swarm.Swarm 18 | err = json.NewDecoder(serverResp.body).Decode(&response) 19 | ensureReaderClosed(serverResp) 20 | return response, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // PluginList returns the installed plugins 11 | func (cli *Client) PluginList(ctx context.Context) (types.PluginsListResponse, error) { 12 | var plugins types.PluginsListResponse 13 | resp, err := cli.get(ctx, "/plugins", nil, nil) 14 | if err != nil { 15 | return plugins, err 16 | } 17 | 18 | err = json.NewDecoder(resp.body).Decode(&plugins) 19 | ensureReaderClosed(resp) 20 | return plugins, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/blkiodev/blkio.go: -------------------------------------------------------------------------------- 1 | package blkiodev 2 | 3 | import "fmt" 4 | 5 | // WeightDevice is a structure that holds device:weight pair 6 | type WeightDevice struct { 7 | Path string 8 | Weight uint16 9 | } 10 | 11 | func (w *WeightDevice) String() string { 12 | return fmt.Sprintf("%s:%d", w.Path, w.Weight) 13 | } 14 | 15 | // ThrottleDevice is a structure that holds device:rate_per_second pair 16 | type ThrottleDevice struct { 17 | Path string 18 | Rate uint64 19 | } 20 | 21 | func (t *ThrottleDevice) String() string { 22 | return fmt.Sprintf("%s:%d", t.Path, t.Rate) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/plugin_interface_type.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // PluginInterfaceType plugin interface type 7 | // swagger:model PluginInterfaceType 8 | type PluginInterfaceType struct { 9 | 10 | // capability 11 | // Required: true 12 | Capability string `json:"Capability"` 13 | 14 | // prefix 15 | // Required: true 16 | Prefix string `json:"Prefix"` 17 | 18 | // version 19 | // Required: true 20 | Version string `json:"Version"` 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_export.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerExport retrieves the raw contents of a container 11 | // and returns them as an io.ReadCloser. It's up to the caller 12 | // to close the stream. 13 | func (cli *Client) ContainerExport(ctx context.Context, containerID string) (io.ReadCloser, error) { 14 | serverResp, err := cli.get(ctx, "/containers/"+containerID+"/export", url.Values{}, nil) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | return serverResp.body, nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_init.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types/swarm" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // SwarmInit initializes the swarm. 11 | func (cli *Client) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) { 12 | serverResp, err := cli.post(ctx, "/swarm/init", nil, req, nil) 13 | if err != nil { 14 | return "", err 15 | } 16 | 17 | var response string 18 | err = json.NewDecoder(serverResp.body).Decode(&response) 19 | ensureReaderClosed(serverResp) 20 | return response, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/tlsconfig/config_client_ciphers.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | // Package tlsconfig provides primitives to retrieve secure-enough TLS configurations for both clients and servers. 4 | // 5 | package tlsconfig 6 | 7 | import ( 8 | "crypto/tls" 9 | ) 10 | 11 | // Client TLS cipher suites (dropping CBC ciphers for client preferred suite set) 12 | var clientCipherSuites = []uint16{ 13 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 14 | tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 15 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16 | tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_save.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ImageSave retrieves one or more images from the docker host as an io.ReadCloser. 11 | // It's up to the caller to store the images and close the stream. 12 | func (cli *Client) ImageSave(ctx context.Context, imageIDs []string) (io.ReadCloser, error) { 13 | query := url.Values{ 14 | "names": imageIDs, 15 | } 16 | 17 | resp, err := cli.get(ctx, "/images/get", query, nil) 18 | if err != nil { 19 | return nil, err 20 | } 21 | return resp.body, nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/version.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ServerVersion returns information of the docker client and server host. 11 | func (cli *Client) ServerVersion(ctx context.Context) (types.Version, error) { 12 | resp, err := cli.get(ctx, "/version", nil, nil) 13 | if err != nil { 14 | return types.Version{}, err 15 | } 16 | 17 | var server types.Version 18 | err = json.NewDecoder(resp.body).Decode(&server) 19 | ensureReaderClosed(resp) 20 | return server, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/volume_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types/versions" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // VolumeRemove removes a volume from the docker host. 11 | func (cli *Client) VolumeRemove(ctx context.Context, volumeID string, force bool) error { 12 | query := url.Values{} 13 | if versions.GreaterThanOrEqualTo(cli.version, "1.25") { 14 | if force { 15 | query.Set("force", "1") 16 | } 17 | } 18 | resp, err := cli.delete(ctx, "/volumes/"+volumeID, query, nil) 19 | ensureReaderClosed(resp) 20 | return err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/container/container_update.go: -------------------------------------------------------------------------------- 1 | package container 2 | 3 | // ---------------------------------------------------------------------------- 4 | // DO NOT EDIT THIS FILE 5 | // This file was generated by `swagger generate operation` 6 | // 7 | // See hack/generate-swagger-api.sh 8 | // ---------------------------------------------------------------------------- 9 | 10 | // ContainerUpdateOKBody container update o k body 11 | // swagger:model ContainerUpdateOKBody 12 | type ContainerUpdateOKBody struct { 13 | 14 | // warnings 15 | // Required: true 16 | Warnings []string `json:"Warnings"` 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/port.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // Port An open port on a container 7 | // swagger:model Port 8 | type Port struct { 9 | 10 | // IP 11 | IP string `json:"IP,omitempty"` 12 | 13 | // Port on the container 14 | // Required: true 15 | PrivatePort uint16 `json:"PrivatePort"` 16 | 17 | // Port exposed on the host 18 | PublicPort uint16 `json:"PublicPort,omitempty"` 19 | 20 | // type 21 | // Required: true 22 | Type string `json:"Type"` 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/tlsconfig/certpool_go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package tlsconfig 4 | 5 | import ( 6 | "crypto/x509" 7 | "runtime" 8 | 9 | "github.com/Sirupsen/logrus" 10 | ) 11 | 12 | // SystemCertPool returns a copy of the system cert pool, 13 | // returns an error if failed to load or empty pool on windows. 14 | func SystemCertPool() (*x509.CertPool, error) { 15 | certpool, err := x509.SystemCertPool() 16 | if err != nil && runtime.GOOS == "windows" { 17 | logrus.Warnf("Unable to use system certificate pool: %v", err) 18 | return x509.NewCertPool(), nil 19 | } 20 | return certpool, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package cobra 4 | 5 | import ( 6 | "os" 7 | "time" 8 | 9 | "github.com/inconshreveable/mousetrap" 10 | ) 11 | 12 | var preExecHookFn = preExecHook 13 | 14 | // enables an information splash screen on Windows if the CLI is started from explorer.exe. 15 | var MousetrapHelpText string = `This is a command line tool 16 | 17 | You need to open cmd.exe and run it from there. 18 | ` 19 | 20 | func preExecHook(c *Command) { 21 | if mousetrap.StartedByExplorer() { 22 | c.Print(MousetrapHelpText) 23 | time.Sleep(5 * time.Second) 24 | os.Exit(1) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/container/container_wait.go: -------------------------------------------------------------------------------- 1 | package container 2 | 3 | // ---------------------------------------------------------------------------- 4 | // DO NOT EDIT THIS FILE 5 | // This file was generated by `swagger generate operation` 6 | // 7 | // See hack/generate-swagger-api.sh 8 | // ---------------------------------------------------------------------------- 9 | 10 | // ContainerWaitOKBody container wait o k body 11 | // swagger:model ContainerWaitOKBody 12 | type ContainerWaitOKBody struct { 13 | 14 | // Exit code of the container 15 | // Required: true 16 | StatusCode int64 `json:"StatusCode"` 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/plugin_env.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // PluginEnv plugin env 7 | // swagger:model PluginEnv 8 | type PluginEnv struct { 9 | 10 | // description 11 | // Required: true 12 | Description string `json:"Description"` 13 | 14 | // name 15 | // Required: true 16 | Name string `json:"Name"` 17 | 18 | // settable 19 | // Required: true 20 | Settable []string `json:"Settable"` 21 | 22 | // value 23 | // Required: true 24 | Value *string `json:"Value"` 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/reference/normalize.go: -------------------------------------------------------------------------------- 1 | package reference 2 | 3 | var ( 4 | defaultTag = "latest" 5 | ) 6 | 7 | // EnsureTagged adds the default tag "latest" to a reference if it only has 8 | // a repo name. 9 | func EnsureTagged(ref Named) NamedTagged { 10 | namedTagged, ok := ref.(NamedTagged) 11 | if !ok { 12 | namedTagged, err := WithTag(ref, defaultTag) 13 | if err != nil { 14 | // Default tag must be valid, to create a NamedTagged 15 | // type with non-validated input the WithTag function 16 | // should be used instead 17 | panic(err) 18 | } 19 | return namedTagged 20 | } 21 | return namedTagged 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/plugin_device.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // PluginDevice plugin device 7 | // swagger:model PluginDevice 8 | type PluginDevice struct { 9 | 10 | // description 11 | // Required: true 12 | Description string `json:"Description"` 13 | 14 | // name 15 | // Required: true 16 | Name string `json:"Name"` 17 | 18 | // path 19 | // Required: true 20 | Path *string `json:"Path"` 21 | 22 | // settable 23 | // Required: true 24 | Settable []string `json:"Settable"` 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/secret_update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "github.com/docker/docker/api/types/swarm" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // SecretUpdate updates a Secret. Currently, the only part of a secret spec 12 | // which can be updated is Labels. 13 | func (cli *Client) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error { 14 | query := url.Values{} 15 | query.Set("version", strconv.FormatUint(version.Index, 10)) 16 | resp, err := cli.post(ctx, "/secrets/"+id+"/update", query, secret, nil) 17 | ensureReaderClosed(resp) 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_connect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types" 5 | "github.com/docker/docker/api/types/network" 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // NetworkConnect connects a container to an existent network in the docker host. 10 | func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error { 11 | nc := types.NetworkConnect{ 12 | Container: containerID, 13 | EndpointConfig: config, 14 | } 15 | resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, nc, nil) 16 | ensureReaderClosed(resp) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_get_unlock_key.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // SwarmGetUnlockKey retrieves the swarm's unlock key. 11 | func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) { 12 | serverResp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil) 13 | if err != nil { 14 | return types.SwarmUnlockKeyResponse{}, err 15 | } 16 | 17 | var response types.SwarmUnlockKeyResponse 18 | err = json.NewDecoder(serverResp.body).Decode(&response) 19 | ensureReaderClosed(serverResp) 20 | return response, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/checkpoint_delete.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // CheckpointDelete deletes the checkpoint with the given name from the given container 11 | func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options types.CheckpointDeleteOptions) error { 12 | query := url.Values{} 13 | if options.CheckpointDir != "" { 14 | query.Set("dir", options.CheckpointDir) 15 | } 16 | 17 | resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil) 18 | ensureReaderClosed(resp) 19 | return err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_history.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ImageHistory returns the changes in an image in history format. 12 | func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]types.ImageHistory, error) { 13 | var history []types.ImageHistory 14 | serverResp, err := cli.get(ctx, "/images/"+imageID+"/history", url.Values{}, nil) 15 | if err != nil { 16 | return history, err 17 | } 18 | 19 | err = json.NewDecoder(serverResp.body).Decode(&history) 20 | ensureReaderClosed(serverResp) 21 | return history, err 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/volume_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | volumetypes "github.com/docker/docker/api/types/volume" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // VolumeCreate creates a volume in the docker host. 12 | func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) { 13 | var volume types.Volume 14 | resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) 15 | if err != nil { 16 | return volume, err 17 | } 18 | err = json.NewDecoder(resp.body).Decode(&volume) 19 | ensureReaderClosed(resp) 20 | return volume, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/interface_experimental.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | type apiClientExperimental interface { 9 | CheckpointAPIClient 10 | } 11 | 12 | // CheckpointAPIClient defines API client methods for the checkpoints 13 | type CheckpointAPIClient interface { 14 | CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error 15 | CheckpointDelete(ctx context.Context, container string, options types.CheckpointDeleteOptions) error 16 | CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/info.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/docker/docker/api/types" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // Info returns information about the docker server. 13 | func (cli *Client) Info(ctx context.Context) (types.Info, error) { 14 | var info types.Info 15 | serverResp, err := cli.get(ctx, "/info", url.Values{}, nil) 16 | if err != nil { 17 | return info, err 18 | } 19 | defer ensureReaderClosed(serverResp) 20 | 21 | if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil { 22 | return info, fmt.Errorf("Error reading remote info: %v", err) 23 | } 24 | 25 | return info, nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/disk_usage.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // DiskUsage requests the current data usage from the daemon 12 | func (cli *Client) DiskUsage(ctx context.Context) (types.DiskUsage, error) { 13 | var du types.DiskUsage 14 | 15 | serverResp, err := cli.get(ctx, "/system/df", nil, nil) 16 | if err != nil { 17 | return du, err 18 | } 19 | defer ensureReaderClosed(serverResp) 20 | 21 | if err := json.NewDecoder(serverResp.body).Decode(&du); err != nil { 22 | return du, fmt.Errorf("Error retrieving disk usage: %v", err) 23 | } 24 | 25 | return du, nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | // +build !appengine 8 | 9 | package logrus 10 | 11 | import ( 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | // IsTerminal returns true if stderr's file descriptor is a terminal. 17 | func IsTerminal() bool { 18 | fd := syscall.Stderr 19 | var termios Termios 20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 21 | return err == 0 22 | } 23 | -------------------------------------------------------------------------------- /cmd/buildcache/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/Sirupsen/logrus" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var ( 11 | mainCmd = &cobra.Command{ 12 | Use: os.Args[0], 13 | Short: "Manage Docker build cache", 14 | // SilenceUsage: true, 15 | // SilenceErrors: true, 16 | } 17 | ) 18 | 19 | func init() { 20 | logrus.SetLevel(logrus.DebugLevel) 21 | 22 | mainCmd.PersistentFlags().StringP("host", "H", "unix:///var/lib/docker.sock", "Docker socket to connect to") 23 | 24 | mainCmd.AddCommand( 25 | saveCmd, 26 | // loadCmd, 27 | // pushCmd, 28 | // pullCmd, 29 | ) 30 | } 31 | 32 | func main() { 33 | if err := mainCmd.Execute(); err != nil { 34 | logrus.Fatal(err) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/digest/digester.go: -------------------------------------------------------------------------------- 1 | package digest 2 | 3 | import "hash" 4 | 5 | // Digester calculates the digest of written data. Writes should go directly 6 | // to the return value of Hash, while calling Digest will return the current 7 | // value of the digest. 8 | type Digester interface { 9 | Hash() hash.Hash // provides direct access to underlying hash instance. 10 | Digest() Digest 11 | } 12 | 13 | // digester provides a simple digester definition that embeds a hasher. 14 | type digester struct { 15 | alg Algorithm 16 | hash hash.Hash 17 | } 18 | 19 | func (d *digester) Hash() hash.Hash { 20 | return d.hash 21 | } 22 | 23 | func (d *digester) Digest() Digest { 24 | return NewDigest(d.alg, d.hash) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/go-digest/digester.go: -------------------------------------------------------------------------------- 1 | package digest 2 | 3 | import "hash" 4 | 5 | // Digester calculates the digest of written data. Writes should go directly 6 | // to the return value of Hash, while calling Digest will return the current 7 | // value of the digest. 8 | type Digester interface { 9 | Hash() hash.Hash // provides direct access to underlying hash instance. 10 | Digest() Digest 11 | } 12 | 13 | // digester provides a simple digester definition that embeds a hasher. 14 | type digester struct { 15 | alg Algorithm 16 | hash hash.Hash 17 | } 18 | 19 | func (d *digester) Hash() hash.Hash { 20 | return d.hash 21 | } 22 | 23 | func (d *digester) Digest() Digest { 24 | return NewDigest(d.alg, d.hash) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/NOTICE: -------------------------------------------------------------------------------- 1 | Docker 2 | Copyright 2012-2016 Docker, Inc. 3 | 4 | This product includes software developed at Docker, Inc. (https://www.docker.com). 5 | 6 | This product contains software (https://github.com/kr/pty) developed 7 | by Keith Rarick, licensed under the MIT License. 8 | 9 | The following is courtesy of our legal counsel: 10 | 11 | 12 | Use and transfer of Docker may be subject to certain restrictions by the 13 | United States and other governments. 14 | It is your responsibility to ensure that your use and/or transfer does not 15 | violate applicable laws. 16 | 17 | For more information, please see https://www.bis.doc.gov 18 | 19 | See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_diff.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ContainerDiff shows differences in a container filesystem since it was started. 12 | func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) { 13 | var changes []types.ContainerChange 14 | 15 | serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil) 16 | if err != nil { 17 | return changes, err 18 | } 19 | 20 | err = json.NewDecoder(serverResp.body).Decode(&changes) 21 | ensureReaderClosed(serverResp) 22 | return changes, err 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_stop.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "time" 6 | 7 | timetypes "github.com/docker/docker/api/types/time" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ContainerStop stops a container without terminating the process. 12 | // The process is blocked until the container stops or the timeout expires. 13 | func (cli *Client) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error { 14 | query := url.Values{} 15 | if timeout != nil { 16 | query.Set("t", timetypes.DurationToSecondsString(*timeout)) 17 | } 18 | resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil) 19 | ensureReaderClosed(resp) 20 | return err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/secret_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "github.com/docker/docker/api/types/swarm" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // SecretCreate creates a new Secret. 12 | func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) { 13 | var headers map[string][]string 14 | 15 | var response types.SecretCreateResponse 16 | resp, err := cli.post(ctx, "/secrets/create", nil, secret, headers) 17 | if err != nil { 18 | return response, err 19 | } 20 | 21 | err = json.NewDecoder(resp.body).Decode(&response) 22 | ensureReaderClosed(resp) 23 | return response, err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/tcp_socket.go: -------------------------------------------------------------------------------- 1 | // Package sockets provides helper functions to create and configure Unix or TCP sockets. 2 | package sockets 3 | 4 | import ( 5 | "crypto/tls" 6 | "net" 7 | ) 8 | 9 | // NewTCPSocket creates a TCP socket listener with the specified address and 10 | // the specified tls configuration. If TLSConfig is set, will encapsulate the 11 | // TCP listener inside a TLS one. 12 | func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) { 13 | l, err := net.Listen("tcp", addr) 14 | if err != nil { 15 | return nil, err 16 | } 17 | if tlsConfig != nil { 18 | tlsConfig.NextProtos = []string{"http/1.1"} 19 | l = tls.NewListener(l, tlsConfig) 20 | } 21 | return l, nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerRemove kills and removes a container from the docker host. 11 | func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { 12 | query := url.Values{} 13 | if options.RemoveVolumes { 14 | query.Set("v", "1") 15 | } 16 | if options.RemoveLinks { 17 | query.Set("link", "1") 18 | } 19 | 20 | if options.Force { 21 | query.Set("force", "1") 22 | } 23 | 24 | resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil) 25 | ensureReaderClosed(resp) 26 | return err 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "net/url" 7 | 8 | "github.com/docker/docker/api/types" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // PluginCreate creates a plugin 13 | func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error { 14 | headers := http.Header(make(map[string][]string)) 15 | headers.Set("Content-Type", "application/x-tar") 16 | 17 | query := url.Values{} 18 | query.Set("name", createOptions.RepoName) 19 | 20 | resp, err := cli.postRaw(ctx, "/plugins/create", query, createContext, headers) 21 | if err != nil { 22 | return err 23 | } 24 | ensureReaderClosed(resp) 25 | return err 26 | } 27 | -------------------------------------------------------------------------------- /vendor.conf: -------------------------------------------------------------------------------- 1 | github.com/Sirupsen/logrus 61e43dc76f7ee59a82bdf3d71033dc12bea4c77d 2 | github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448 3 | golang.org/x/net/context f2499483f923065a842d38eb4c7f1927e6fc6e6d 4 | github.com/docker/docker 0e8c7d72771847227df295471ac73180cbb3caa9 5 | github.com/dustin/go-humanize 7a41df006ff9af79a29f0ffa9c5f21fbe6314a2d 6 | golang.org/x/crypto b8a2a83acfe6e6770b75de42d5ff4c67596675c0 7 | github.com/docker/go-connections eb315e36415380e7c2fdee175262560ff42359da 8 | github.com/spf13/cobra dc208f4211e7f6df7ec8cb62640f57d3e154910d 9 | github.com/docker/go-units e30f1e79f3cd72542f2026ceec18d3bd67ab859c 10 | github.com/spf13/pflag 51268031d79952516489a9f8aa34e9709b98d946 11 | github.com/pkg/errors 248dadf4e9068a0b3e79f02ed0a610d935de5302 -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types/container" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerUpdate updates resources of a container 11 | func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) { 12 | var response container.ContainerUpdateOKBody 13 | serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil) 14 | if err != nil { 15 | return response, err 16 | } 17 | 18 | err = json.NewDecoder(serverResp.body).Decode(&response) 19 | 20 | ensureReaderClosed(serverResp) 21 | return response, err 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/swarm/secret.go: -------------------------------------------------------------------------------- 1 | package swarm 2 | 3 | import "os" 4 | 5 | // Secret represents a secret. 6 | type Secret struct { 7 | ID string 8 | Meta 9 | Spec SecretSpec 10 | } 11 | 12 | // SecretSpec represents a secret specification from a secret in swarm 13 | type SecretSpec struct { 14 | Annotations 15 | Data []byte `json:",omitempty"` 16 | } 17 | 18 | // SecretReferenceFileTarget is a file target in a secret reference 19 | type SecretReferenceFileTarget struct { 20 | Name string 21 | UID string 22 | GID string 23 | Mode os.FileMode 24 | } 25 | 26 | // SecretReference is a reference to a secret in swarm 27 | type SecretReference struct { 28 | File *SecretReferenceFileTarget 29 | SecretID string 30 | SecretName string 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_start.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "golang.org/x/net/context" 7 | 8 | "github.com/docker/docker/api/types" 9 | ) 10 | 11 | // ContainerStart sends a request to the docker daemon to start a container. 12 | func (cli *Client) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error { 13 | query := url.Values{} 14 | if len(options.CheckpointID) != 0 { 15 | query.Set("checkpoint", options.CheckpointID) 16 | } 17 | if len(options.CheckpointDir) != 0 { 18 | query.Set("checkpoint-dir", options.CheckpointDir) 19 | } 20 | 21 | resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil) 22 | ensureReaderClosed(resp) 23 | return err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/transport.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "crypto/tls" 5 | "net/http" 6 | ) 7 | 8 | // transportFunc allows us to inject a mock transport for testing. We define it 9 | // here so we can detect the tlsconfig and return nil for only this type. 10 | type transportFunc func(*http.Request) (*http.Response, error) 11 | 12 | func (tf transportFunc) RoundTrip(req *http.Request) (*http.Response, error) { 13 | return tf(req) 14 | } 15 | 16 | // resolveTLSConfig attempts to resolve the TLS configuration from the 17 | // RoundTripper. 18 | func resolveTLSConfig(transport http.RoundTripper) *tls.Config { 19 | switch tr := transport.(type) { 20 | case *http.Transport: 21 | return tr.TLSClientConfig 22 | default: 23 | return nil 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/big.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "math/big" 5 | ) 6 | 7 | // order of magnitude (to a max order) 8 | func oomm(n, b *big.Int, maxmag int) (float64, int) { 9 | mag := 0 10 | m := &big.Int{} 11 | for n.Cmp(b) >= 0 { 12 | n.DivMod(n, b, m) 13 | mag++ 14 | if mag == maxmag && maxmag >= 0 { 15 | break 16 | } 17 | } 18 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 19 | } 20 | 21 | // total order of magnitude 22 | // (same as above, but with no upper limit) 23 | func oom(n, b *big.Int) (float64, int) { 24 | mag := 0 25 | m := &big.Int{} 26 | for n.Cmp(b) >= 0 { 27 | n.DivMod(n, b, m) 28 | mag++ 29 | } 30 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/container/container_create.go: -------------------------------------------------------------------------------- 1 | package container 2 | 3 | // ---------------------------------------------------------------------------- 4 | // DO NOT EDIT THIS FILE 5 | // This file was generated by `swagger generate operation` 6 | // 7 | // See hack/generate-swagger-api.sh 8 | // ---------------------------------------------------------------------------- 9 | 10 | // ContainerCreateCreatedBody container create created body 11 | // swagger:model ContainerCreateCreatedBody 12 | type ContainerCreateCreatedBody struct { 13 | 14 | // The ID of the created container 15 | // Required: true 16 | ID string `json:"Id"` 17 | 18 | // Warnings encountered when creating the container 19 | // Required: true 20 | Warnings []string `json:"Warnings"` 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/registry/authenticate.go: -------------------------------------------------------------------------------- 1 | package registry 2 | 3 | // ---------------------------------------------------------------------------- 4 | // DO NOT EDIT THIS FILE 5 | // This file was generated by `swagger generate operation` 6 | // 7 | // See hack/generate-swagger-api.sh 8 | // ---------------------------------------------------------------------------- 9 | 10 | // AuthenticateOKBody authenticate o k body 11 | // swagger:model AuthenticateOKBody 12 | type AuthenticateOKBody struct { 13 | 14 | // An opaque token used to authenticate a user after a successful login 15 | // Required: true 16 | IdentityToken string `json:"IdentityToken"` 17 | 18 | // The status of the authentication 19 | // Required: true 20 | Status string `json:"Status"` 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_restart.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "time" 6 | 7 | timetypes "github.com/docker/docker/api/types/time" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ContainerRestart stops and starts a container again. 12 | // It makes the daemon to wait for the container to be up again for 13 | // a specific amount of time, given the timeout. 14 | func (cli *Client) ContainerRestart(ctx context.Context, containerID string, timeout *time.Duration) error { 15 | query := url.Values{} 16 | if timeout != nil { 17 | query.Set("t", timetypes.DurationToSecondsString(*timeout)) 18 | } 19 | resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil) 20 | ensureReaderClosed(resp) 21 | return err 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/unix_socket.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package sockets 4 | 5 | import ( 6 | "net" 7 | "os" 8 | "syscall" 9 | ) 10 | 11 | // NewUnixSocket creates a unix socket with the specified path and group. 12 | func NewUnixSocket(path string, gid int) (net.Listener, error) { 13 | if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) { 14 | return nil, err 15 | } 16 | mask := syscall.Umask(0777) 17 | defer syscall.Umask(mask) 18 | 19 | l, err := net.Listen("unix", path) 20 | if err != nil { 21 | return nil, err 22 | } 23 | if err := os.Chown(path, 0, gid); err != nil { 24 | return nil, err 25 | } 26 | if err := os.Chmod(path, 0660); err != nil { 27 | l.Close() 28 | return nil, err 29 | } 30 | return l, nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_wait.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "golang.org/x/net/context" 7 | 8 | "github.com/docker/docker/api/types/container" 9 | ) 10 | 11 | // ContainerWait pauses execution until a container exits. 12 | // It returns the API status code as response of its readiness. 13 | func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int64, error) { 14 | resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil) 15 | if err != nil { 16 | return -1, err 17 | } 18 | defer ensureReaderClosed(resp) 19 | 20 | var res container.ContainerWaitOKBody 21 | if err := json.NewDecoder(resp.body).Decode(&res); err != nil { 22 | return -1, err 23 | } 24 | 25 | return res.StatusCode, nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/sockets_windows.go: -------------------------------------------------------------------------------- 1 | package sockets 2 | 3 | import ( 4 | "net" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/Microsoft/go-winio" 9 | ) 10 | 11 | func configureUnixTransport(tr *http.Transport, proto, addr string) error { 12 | return ErrProtocolNotAvailable 13 | } 14 | 15 | func configureNpipeTransport(tr *http.Transport, proto, addr string) error { 16 | // No need for compression in local communications. 17 | tr.DisableCompression = true 18 | tr.Dial = func(_, _ string) (net.Conn, error) { 19 | return DialPipe(addr, defaultTimeout) 20 | } 21 | return nil 22 | } 23 | 24 | // DialPipe connects to a Windows named pipe. 25 | func DialPipe(addr string, timeout time.Duration) (net.Conn, error) { 26 | return winio.DialPipe(addr, &timeout) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows,!appengine 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/volume/volumes_list.go: -------------------------------------------------------------------------------- 1 | package volume 2 | 3 | // ---------------------------------------------------------------------------- 4 | // DO NOT EDIT THIS FILE 5 | // This file was generated by `swagger generate operation` 6 | // 7 | // See hack/generate-swagger-api.sh 8 | // ---------------------------------------------------------------------------- 9 | 10 | import "github.com/docker/docker/api/types" 11 | 12 | // VolumesListOKBody volumes list o k body 13 | // swagger:model VolumesListOKBody 14 | type VolumesListOKBody struct { 15 | 16 | // List of volumes 17 | // Required: true 18 | Volumes []*types.Volume `json:"Volumes"` 19 | 20 | // Warnings that occurred when fetching the list of volumes 21 | // Required: true 22 | Warnings []string `json:"Warnings"` 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // NetworkCreate creates a new network in the docker host. 11 | func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { 12 | networkCreateRequest := types.NetworkCreateRequest{ 13 | NetworkCreate: options, 14 | Name: name, 15 | } 16 | var response types.NetworkCreateResponse 17 | serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil) 18 | if err != nil { 19 | return response, err 20 | } 21 | 22 | json.NewDecoder(serverResp.body).Decode(&response) 23 | ensureReaderClosed(serverResp) 24 | return response, err 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/swarm/common.go: -------------------------------------------------------------------------------- 1 | package swarm 2 | 3 | import "time" 4 | 5 | // Version represents the internal object version. 6 | type Version struct { 7 | Index uint64 `json:",omitempty"` 8 | } 9 | 10 | // Meta is a base object inherited by most of the other once. 11 | type Meta struct { 12 | Version Version `json:",omitempty"` 13 | CreatedAt time.Time `json:",omitempty"` 14 | UpdatedAt time.Time `json:",omitempty"` 15 | } 16 | 17 | // Annotations represents how to describe an object. 18 | type Annotations struct { 19 | Name string `json:",omitempty"` 20 | Labels map[string]string `json:",omitempty"` 21 | } 22 | 23 | // Driver represents a driver (network, logging). 24 | type Driver struct { 25 | Name string `json:",omitempty"` 26 | Options map[string]string `json:",omitempty"` 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ImageRemove removes an image from the docker host. 12 | func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDelete, error) { 13 | query := url.Values{} 14 | 15 | if options.Force { 16 | query.Set("force", "1") 17 | } 18 | if !options.PruneChildren { 19 | query.Set("noprune", "1") 20 | } 21 | 22 | resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) 23 | if err != nil { 24 | return nil, err 25 | } 26 | 27 | var dels []types.ImageDelete 28 | err = json.NewDecoder(resp.body).Decode(&dels) 29 | ensureReaderClosed(resp) 30 | return dels, err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/swarm_update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "strconv" 7 | 8 | "github.com/docker/docker/api/types/swarm" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // SwarmUpdate updates the swarm. 13 | func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error { 14 | query := url.Values{} 15 | query.Set("version", strconv.FormatUint(version.Index, 10)) 16 | query.Set("rotateWorkerToken", fmt.Sprintf("%v", flags.RotateWorkerToken)) 17 | query.Set("rotateManagerToken", fmt.Sprintf("%v", flags.RotateManagerToken)) 18 | query.Set("rotateManagerUnlockKey", fmt.Sprintf("%v", flags.RotateManagerUnlockKey)) 19 | resp, err := cli.post(ctx, "/swarm/update", query, swarm, nil) 20 | ensureReaderClosed(resp) 21 | return err 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_stats.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerStats returns near realtime stats for a given container. 11 | // It's up to the caller to close the io.ReadCloser returned. 12 | func (cli *Client) ContainerStats(ctx context.Context, containerID string, stream bool) (types.ContainerStats, error) { 13 | query := url.Values{} 14 | query.Set("stream", "0") 15 | if stream { 16 | query.Set("stream", "1") 17 | } 18 | 19 | resp, err := cli.get(ctx, "/containers/"+containerID+"/stats", query, nil) 20 | if err != nil { 21 | return types.ContainerStats{}, err 22 | } 23 | 24 | osType := getDockerOS(resp.header.Get("Server")) 25 | return types.ContainerStats{Body: resp.body, OSType: osType}, err 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_top.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strings" 7 | 8 | "github.com/docker/docker/api/types" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // ContainerTop shows process information from within a container. 13 | func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) { 14 | var response types.ContainerProcessList 15 | query := url.Values{} 16 | if len(arguments) > 0 { 17 | query.Set("ps_args", strings.Join(arguments, " ")) 18 | } 19 | 20 | resp, err := cli.get(ctx, "/containers/"+containerID+"/top", query, nil) 21 | if err != nil { 22 | return response, err 23 | } 24 | 25 | err = json.NewDecoder(resp.body).Decode(&response) 26 | ensureReaderClosed(resp) 27 | return response, err 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/ping.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // Ping pings the server and returns the value of the "Docker-Experimental" & "API-Version" headers 11 | func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { 12 | var ping types.Ping 13 | req, err := cli.buildRequest("GET", fmt.Sprintf("%s/_ping", cli.basePath), nil, nil) 14 | if err != nil { 15 | return ping, err 16 | } 17 | serverResp, err := cli.doRequest(ctx, req) 18 | if err != nil { 19 | return ping, err 20 | } 21 | defer ensureReaderClosed(serverResp) 22 | 23 | ping.APIVersion = serverResp.header.Get("API-Version") 24 | 25 | if serverResp.header.Get("Docker-Experimental") == "true" { 26 | ping.Experimental = true 27 | } 28 | 29 | return ping, nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/checkpoint_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // CheckpointList returns the volumes configured in the docker host. 12 | func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { 13 | var checkpoints []types.Checkpoint 14 | 15 | query := url.Values{} 16 | if options.CheckpointDir != "" { 17 | query.Set("dir", options.CheckpointDir) 18 | } 19 | 20 | resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil) 21 | if err != nil { 22 | return checkpoints, err 23 | } 24 | 25 | err = json.NewDecoder(resp.body).Decode(&checkpoints) 26 | ensureReaderClosed(resp) 27 | return checkpoints, err 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/auth.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // AuthConfig contains authorization information for connecting to a Registry 4 | type AuthConfig struct { 5 | Username string `json:"username,omitempty"` 6 | Password string `json:"password,omitempty"` 7 | Auth string `json:"auth,omitempty"` 8 | 9 | // Email is an optional value associated with the username. 10 | // This field is deprecated and will be removed in a later 11 | // version of docker. 12 | Email string `json:"email,omitempty"` 13 | 14 | ServerAddress string `json:"serveraddress,omitempty"` 15 | 16 | // IdentityToken is used to authenticate the user and get 17 | // an access token for the registry. 18 | IdentityToken string `json:"identitytoken,omitempty"` 19 | 20 | // RegistryToken is a bearer token to be sent to a registry 21 | RegistryToken string `json:"registrytoken,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/go-digest/verifiers.go: -------------------------------------------------------------------------------- 1 | package digest 2 | 3 | import ( 4 | "hash" 5 | "io" 6 | ) 7 | 8 | // Verifier presents a general verification interface to be used with message 9 | // digests and other byte stream verifications. Users instantiate a Verifier 10 | // from one of the various methods, write the data under test to it then check 11 | // the result with the Verified method. 12 | type Verifier interface { 13 | io.Writer 14 | 15 | // Verified will return true if the content written to Verifier matches 16 | // the digest. 17 | Verified() bool 18 | } 19 | 20 | type hashVerifier struct { 21 | digest Digest 22 | hash hash.Hash 23 | } 24 | 25 | func (hv hashVerifier) Write(p []byte) (n int, err error) { 26 | return hv.hash.Write(p) 27 | } 28 | 29 | func (hv hashVerifier) Verified() bool { 30 | return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/plugin_mount.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // PluginMount plugin mount 7 | // swagger:model PluginMount 8 | type PluginMount struct { 9 | 10 | // description 11 | // Required: true 12 | Description string `json:"Description"` 13 | 14 | // destination 15 | // Required: true 16 | Destination string `json:"Destination"` 17 | 18 | // name 19 | // Required: true 20 | Name string `json:"Name"` 21 | 22 | // options 23 | // Required: true 24 | Options []string `json:"Options"` 25 | 26 | // settable 27 | // Required: true 28 | Settable []string `json:"Settable"` 29 | 30 | // source 31 | // Required: true 32 | Source *string `json:"Source"` 33 | 34 | // type 35 | // Required: true 36 | Type string `json:"Type"` 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/plugin_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // PluginInspectWithRaw inspects an existing plugin 14 | func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { 15 | resp, err := cli.get(ctx, "/plugins/"+name+"/json", nil, nil) 16 | if err != nil { 17 | if resp.statusCode == http.StatusNotFound { 18 | return nil, nil, pluginNotFoundError{name} 19 | } 20 | return nil, nil, err 21 | } 22 | 23 | defer ensureReaderClosed(resp) 24 | body, err := ioutil.ReadAll(resp.body) 25 | if err != nil { 26 | return nil, nil, err 27 | } 28 | var p types.Plugin 29 | rdr := bytes.NewReader(body) 30 | err = json.NewDecoder(rdr).Decode(&p) 31 | return &p, body, err 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/task_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // TaskList returns the list of tasks. 14 | func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { 15 | query := url.Values{} 16 | 17 | if options.Filters.Len() > 0 { 18 | filterJSON, err := filters.ToParam(options.Filters) 19 | if err != nil { 20 | return nil, err 21 | } 22 | 23 | query.Set("filters", filterJSON) 24 | } 25 | 26 | resp, err := cli.get(ctx, "/tasks", query, nil) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | var tasks []swarm.Task 32 | err = json.NewDecoder(resp.body).Decode(&tasks) 33 | ensureReaderClosed(resp) 34 | return tasks, err 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/strslice/strslice.go: -------------------------------------------------------------------------------- 1 | package strslice 2 | 3 | import "encoding/json" 4 | 5 | // StrSlice represents a string or an array of strings. 6 | // We need to override the json decoder to accept both options. 7 | type StrSlice []string 8 | 9 | // UnmarshalJSON decodes the byte slice whether it's a string or an array of 10 | // strings. This method is needed to implement json.Unmarshaler. 11 | func (e *StrSlice) UnmarshalJSON(b []byte) error { 12 | if len(b) == 0 { 13 | // With no input, we preserve the existing value by returning nil and 14 | // leaving the target alone. This allows defining default values for 15 | // the type. 16 | return nil 17 | } 18 | 19 | p := make([]string, 0, 1) 20 | if err := json.Unmarshal(b, &p); err != nil { 21 | var s string 22 | if err := json.Unmarshal(b, &s); err != nil { 23 | return err 24 | } 25 | p = append(p, s) 26 | } 27 | 28 | *e = p 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/node_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // NodeList returns the list of nodes. 14 | func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { 15 | query := url.Values{} 16 | 17 | if options.Filters.Len() > 0 { 18 | filterJSON, err := filters.ToParam(options.Filters) 19 | 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | query.Set("filters", filterJSON) 25 | } 26 | 27 | resp, err := cli.get(ctx, "/nodes", query, nil) 28 | if err != nil { 29 | return nil, err 30 | } 31 | 32 | var nodes []swarm.Node 33 | err = json.NewDecoder(resp.body).Decode(&nodes) 34 | ensureReaderClosed(resp) 35 | return nodes, err 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/service_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "github.com/docker/docker/api/types/swarm" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ServiceCreate creates a new Service. 12 | func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) { 13 | var headers map[string][]string 14 | 15 | if options.EncodedRegistryAuth != "" { 16 | headers = map[string][]string{ 17 | "X-Registry-Auth": {options.EncodedRegistryAuth}, 18 | } 19 | } 20 | 21 | var response types.ServiceCreateResponse 22 | resp, err := cli.post(ctx, "/services/create", nil, service, headers) 23 | if err != nil { 24 | return response, err 25 | } 26 | 27 | err = json.NewDecoder(resp.body).Decode(&response) 28 | ensureReaderClosed(resp) 29 | return response, err 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/commaf.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package humanize 4 | 5 | import ( 6 | "bytes" 7 | "math/big" 8 | "strings" 9 | ) 10 | 11 | // BigCommaf produces a string form of the given big.Float in base 10 12 | // with commas after every three orders of magnitude. 13 | func BigCommaf(v *big.Float) string { 14 | buf := &bytes.Buffer{} 15 | if v.Sign() < 0 { 16 | buf.Write([]byte{'-'}) 17 | v.Abs(v) 18 | } 19 | 20 | comma := []byte{','} 21 | 22 | parts := strings.Split(v.Text('f', -1), ".") 23 | pos := 0 24 | if len(parts[0])%3 != 0 { 25 | pos += len(parts[0]) % 3 26 | buf.WriteString(parts[0][:pos]) 27 | buf.Write(comma) 28 | } 29 | for ; pos < len(parts[0]); pos += 3 { 30 | buf.WriteString(parts[0][pos : pos+3]) 31 | buf.Write(comma) 32 | } 33 | buf.Truncate(buf.Len() - 1) 34 | 35 | if len(parts) > 1 { 36 | buf.Write([]byte{'.'}) 37 | buf.WriteString(parts[1]) 38 | } 39 | return buf.String() 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/utils.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/docker/api/types/filters" 5 | "net/url" 6 | "regexp" 7 | ) 8 | 9 | var headerRegexp = regexp.MustCompile(`\ADocker/.+\s\((.+)\)\z`) 10 | 11 | // getDockerOS returns the operating system based on the server header from the daemon. 12 | func getDockerOS(serverHeader string) string { 13 | var osType string 14 | matches := headerRegexp.FindStringSubmatch(serverHeader) 15 | if len(matches) > 0 { 16 | osType = matches[1] 17 | } 18 | return osType 19 | } 20 | 21 | // getFiltersQuery returns a url query with "filters" query term, based on the 22 | // filters provided. 23 | func getFiltersQuery(f filters.Args) (url.Values, error) { 24 | query := url.Values{} 25 | if f.Len() > 0 { 26 | filterJSON, err := filters.ToParam(f) 27 | if err != nil { 28 | return query, err 29 | } 30 | query.Set("filters", filterJSON) 31 | } 32 | return query, nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_load.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | 9 | "github.com/docker/docker/api/types" 10 | ) 11 | 12 | // ImageLoad loads an image in the docker host from the client host. 13 | // It's up to the caller to close the io.ReadCloser in the 14 | // ImageLoadResponse returned by this function. 15 | func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) { 16 | v := url.Values{} 17 | v.Set("quiet", "0") 18 | if quiet { 19 | v.Set("quiet", "1") 20 | } 21 | headers := map[string][]string{"Content-Type": {"application/x-tar"}} 22 | resp, err := cli.postRaw(ctx, "/images/load", v, input, headers) 23 | if err != nil { 24 | return types.ImageLoadResponse{}, err 25 | } 26 | return types.ImageLoadResponse{ 27 | Body: resp.body, 28 | JSON: resp.header.Get("Content-Type") == "application/json", 29 | }, nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/secret_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // SecretList returns the list of secrets. 14 | func (cli *Client) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { 15 | query := url.Values{} 16 | 17 | if options.Filters.Len() > 0 { 18 | filterJSON, err := filters.ToParam(options.Filters) 19 | if err != nil { 20 | return nil, err 21 | } 22 | 23 | query.Set("filters", filterJSON) 24 | } 25 | 26 | resp, err := cli.get(ctx, "/secrets", query, nil) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | var secrets []swarm.Secret 32 | err = json.NewDecoder(resp.body).Decode(&secrets) 33 | ensureReaderClosed(resp) 34 | return secrets, err 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/service_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ServiceList returns the list of services. 14 | func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) { 15 | query := url.Values{} 16 | 17 | if options.Filters.Len() > 0 { 18 | filterJSON, err := filters.ToParam(options.Filters) 19 | if err != nil { 20 | return nil, err 21 | } 22 | 23 | query.Set("filters", filterJSON) 24 | } 25 | 26 | resp, err := cli.get(ctx, "/services", query, nil) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | var services []swarm.Service 32 | err = json.NewDecoder(resp.body).Decode(&services) 33 | ensureReaderClosed(resp) 34 | return services, err 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/volume_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types/filters" 8 | volumetypes "github.com/docker/docker/api/types/volume" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // VolumeList returns the volumes configured in the docker host. 13 | func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) { 14 | var volumes volumetypes.VolumesListOKBody 15 | query := url.Values{} 16 | 17 | if filter.Len() > 0 { 18 | filterJSON, err := filters.ToParamWithVersion(cli.version, filter) 19 | if err != nil { 20 | return volumes, err 21 | } 22 | query.Set("filters", filterJSON) 23 | } 24 | resp, err := cli.get(ctx, "/volumes", query, nil) 25 | if err != nil { 26 | return volumes, err 27 | } 28 | 29 | err = json.NewDecoder(resp.body).Decode(&volumes) 30 | ensureReaderClosed(resp) 31 | return volumes, err 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/login.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | "net/url" 7 | 8 | "github.com/docker/docker/api/types" 9 | "github.com/docker/docker/api/types/registry" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // RegistryLogin authenticates the docker server with a given docker registry. 14 | // It returns unauthorizedError when the authentication fails. 15 | func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) { 16 | resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) 17 | 18 | if resp.statusCode == http.StatusUnauthorized { 19 | return registry.AuthenticateOKBody{}, unauthorizedError{err} 20 | } 21 | if err != nil { 22 | return registry.AuthenticateOKBody{}, err 23 | } 24 | 25 | var response registry.AuthenticateOKBody 26 | err = json.NewDecoder(resp.body).Decode(&response) 27 | ensureReaderClosed(resp) 28 | return response, err 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/node_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // NodeInspectWithRaw returns the node information. 14 | func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) { 15 | serverResp, err := cli.get(ctx, "/nodes/"+nodeID, nil, nil) 16 | if err != nil { 17 | if serverResp.statusCode == http.StatusNotFound { 18 | return swarm.Node{}, nil, nodeNotFoundError{nodeID} 19 | } 20 | return swarm.Node{}, nil, err 21 | } 22 | defer ensureReaderClosed(serverResp) 23 | 24 | body, err := ioutil.ReadAll(serverResp.body) 25 | if err != nil { 26 | return swarm.Node{}, nil, err 27 | } 28 | 29 | var response swarm.Node 30 | rdr := bytes.NewReader(body) 31 | err = json.NewDecoder(rdr).Decode(&response) 32 | return response, body, err 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/secret_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // SecretInspectWithRaw returns the secret information with raw data 14 | func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { 15 | resp, err := cli.get(ctx, "/secrets/"+id, nil, nil) 16 | if err != nil { 17 | if resp.statusCode == http.StatusNotFound { 18 | return swarm.Secret{}, nil, secretNotFoundError{id} 19 | } 20 | return swarm.Secret{}, nil, err 21 | } 22 | defer ensureReaderClosed(resp) 23 | 24 | body, err := ioutil.ReadAll(resp.body) 25 | if err != nil { 26 | return swarm.Secret{}, nil, err 27 | } 28 | 29 | var secret swarm.Secret 30 | rdr := bytes.NewReader(body) 31 | err = json.NewDecoder(rdr).Decode(&secret) 32 | 33 | return secret, body, err 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // NetworkList returns the list of networks configured in the docker host. 13 | func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { 14 | query := url.Values{} 15 | if options.Filters.Len() > 0 { 16 | filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | query.Set("filters", filterJSON) 22 | } 23 | var networkResources []types.NetworkResource 24 | resp, err := cli.get(ctx, "/networks", query, nil) 25 | if err != nil { 26 | return networkResources, err 27 | } 28 | err = json.NewDecoder(resp.body).Decode(&networkResources) 29 | ensureReaderClosed(resp) 30 | return networkResources, err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/task_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types/swarm" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // TaskInspectWithRaw returns the task information and its raw representation.. 15 | func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) { 16 | serverResp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil) 17 | if err != nil { 18 | if serverResp.statusCode == http.StatusNotFound { 19 | return swarm.Task{}, nil, taskNotFoundError{taskID} 20 | } 21 | return swarm.Task{}, nil, err 22 | } 23 | defer ensureReaderClosed(serverResp) 24 | 25 | body, err := ioutil.ReadAll(serverResp.body) 26 | if err != nil { 27 | return swarm.Task{}, nil, err 28 | } 29 | 30 | var response swarm.Task 31 | rdr := bytes.NewReader(body) 32 | err = json.NewDecoder(rdr).Decode(&response) 33 | return response, body, err 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/service_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ServiceInspectWithRaw returns the service information and the raw data. 14 | func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string) (swarm.Service, []byte, error) { 15 | serverResp, err := cli.get(ctx, "/services/"+serviceID, nil, nil) 16 | if err != nil { 17 | if serverResp.statusCode == http.StatusNotFound { 18 | return swarm.Service{}, nil, serviceNotFoundError{serviceID} 19 | } 20 | return swarm.Service{}, nil, err 21 | } 22 | defer ensureReaderClosed(serverResp) 23 | 24 | body, err := ioutil.ReadAll(serverResp.body) 25 | if err != nil { 26 | return swarm.Service{}, nil, err 27 | } 28 | 29 | var response swarm.Service 30 | rdr := bytes.NewReader(body) 31 | err = json.NewDecoder(rdr).Decode(&response) 32 | return response, body, err 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/sockets_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package sockets 4 | 5 | import ( 6 | "fmt" 7 | "net" 8 | "net/http" 9 | "syscall" 10 | "time" 11 | ) 12 | 13 | const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) 14 | 15 | func configureUnixTransport(tr *http.Transport, proto, addr string) error { 16 | if len(addr) > maxUnixSocketPathSize { 17 | return fmt.Errorf("Unix socket path %q is too long", addr) 18 | } 19 | // No need for compression in local communications. 20 | tr.DisableCompression = true 21 | tr.Dial = func(_, _ string) (net.Conn, error) { 22 | return net.DialTimeout(proto, addr, defaultTimeout) 23 | } 24 | return nil 25 | } 26 | 27 | func configureNpipeTransport(tr *http.Transport, proto, addr string) error { 28 | return ErrProtocolNotAvailable 29 | } 30 | 31 | // DialPipe connects to a Windows named pipe. 32 | // This is not supported on other OSes. 33 | func DialPipe(_ string, _ time.Duration) (net.Conn, error) { 34 | return nil, syscall.EAFNOSUPPORT 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ImageInspectWithRaw returns the image information and its raw representation. 14 | func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { 15 | serverResp, err := cli.get(ctx, "/images/"+imageID+"/json", nil, nil) 16 | if err != nil { 17 | if serverResp.statusCode == http.StatusNotFound { 18 | return types.ImageInspect{}, nil, imageNotFoundError{imageID} 19 | } 20 | return types.ImageInspect{}, nil, err 21 | } 22 | defer ensureReaderClosed(serverResp) 23 | 24 | body, err := ioutil.ReadAll(serverResp.body) 25 | if err != nil { 26 | return types.ImageInspect{}, nil, err 27 | } 28 | 29 | var response types.ImageInspect 30 | rdr := bytes.NewReader(body) 31 | err = json.NewDecoder(rdr).Decode(&response) 32 | return response, body, err 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_prune.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // ImagesPrune requests the daemon to delete unused data 13 | func (cli *Client) ImagesPrune(ctx context.Context, pruneFilters filters.Args) (types.ImagesPruneReport, error) { 14 | var report types.ImagesPruneReport 15 | 16 | if err := cli.NewVersionError("1.25", "image prune"); err != nil { 17 | return report, err 18 | } 19 | 20 | query, err := getFiltersQuery(pruneFilters) 21 | if err != nil { 22 | return report, err 23 | } 24 | 25 | serverResp, err := cli.post(ctx, "/images/prune", query, nil, nil) 26 | if err != nil { 27 | return report, err 28 | } 29 | defer ensureReaderClosed(serverResp) 30 | 31 | if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { 32 | return report, fmt.Errorf("Error retrieving disk usage: %v", err) 33 | } 34 | 35 | return report, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/digest/verifiers.go: -------------------------------------------------------------------------------- 1 | package digest 2 | 3 | import ( 4 | "hash" 5 | "io" 6 | ) 7 | 8 | // Verifier presents a general verification interface to be used with message 9 | // digests and other byte stream verifications. Users instantiate a Verifier 10 | // from one of the various methods, write the data under test to it then check 11 | // the result with the Verified method. 12 | type Verifier interface { 13 | io.Writer 14 | 15 | // Verified will return true if the content written to Verifier matches 16 | // the digest. 17 | Verified() bool 18 | } 19 | 20 | // NewDigestVerifier is deprecated. Please use Digest.Verifier. 21 | func NewDigestVerifier(d Digest) (Verifier, error) { 22 | return d.Verifier(), nil 23 | } 24 | 25 | type hashVerifier struct { 26 | digest Digest 27 | hash hash.Hash 28 | } 29 | 30 | func (hv hashVerifier) Write(p []byte) (n int, err error) { 31 | return hv.hash.Write(p) 32 | } 33 | 34 | func (hv hashVerifier) Verified() bool { 35 | return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/volume_prune.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // VolumesPrune requests the daemon to delete unused data 13 | func (cli *Client) VolumesPrune(ctx context.Context, pruneFilters filters.Args) (types.VolumesPruneReport, error) { 14 | var report types.VolumesPruneReport 15 | 16 | if err := cli.NewVersionError("1.25", "volume prune"); err != nil { 17 | return report, err 18 | } 19 | 20 | query, err := getFiltersQuery(pruneFilters) 21 | if err != nil { 22 | return report, err 23 | } 24 | 25 | serverResp, err := cli.post(ctx, "/volumes/prune", query, nil, nil) 26 | if err != nil { 27 | return report, err 28 | } 29 | defer ensureReaderClosed(serverResp) 30 | 31 | if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { 32 | return report, fmt.Errorf("Error retrieving disk usage: %v", err) 33 | } 34 | 35 | return report, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/volume/volumes_create.go: -------------------------------------------------------------------------------- 1 | package volume 2 | 3 | // ---------------------------------------------------------------------------- 4 | // DO NOT EDIT THIS FILE 5 | // This file was generated by `swagger generate operation` 6 | // 7 | // See hack/generate-swagger-api.sh 8 | // ---------------------------------------------------------------------------- 9 | 10 | // VolumesCreateBody volumes create body 11 | // swagger:model VolumesCreateBody 12 | type VolumesCreateBody struct { 13 | 14 | // Name of the volume driver to use. 15 | // Required: true 16 | Driver string `json:"Driver"` 17 | 18 | // A mapping of driver options and values. These options are passed directly to the driver and are driver specific. 19 | // Required: true 20 | DriverOpts map[string]string `json:"DriverOpts"` 21 | 22 | // User-defined key/value metadata. 23 | // Required: true 24 | Labels map[string]string `json:"Labels"` 25 | 26 | // The new volume's name. If not specified, Docker generates a name. 27 | // Required: true 28 | Name string `json:"Name"` 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_prune.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // ContainersPrune requests the daemon to delete unused data 13 | func (cli *Client) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) { 14 | var report types.ContainersPruneReport 15 | 16 | if err := cli.NewVersionError("1.25", "container prune"); err != nil { 17 | return report, err 18 | } 19 | 20 | query, err := getFiltersQuery(pruneFilters) 21 | if err != nil { 22 | return report, err 23 | } 24 | 25 | serverResp, err := cli.post(ctx, "/containers/prune", query, nil, nil) 26 | if err != nil { 27 | return report, err 28 | } 29 | defer ensureReaderClosed(serverResp) 30 | 31 | if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { 32 | return report, fmt.Errorf("Error retrieving disk usage: %v", err) 33 | } 34 | 35 | return report, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_prune.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // NetworksPrune requests the daemon to delete unused networks 13 | func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) { 14 | var report types.NetworksPruneReport 15 | 16 | if err := cli.NewVersionError("1.25", "network prune"); err != nil { 17 | return report, err 18 | } 19 | 20 | query, err := getFiltersQuery(pruneFilters) 21 | if err != nil { 22 | return report, err 23 | } 24 | 25 | serverResp, err := cli.post(ctx, "/networks/prune", query, nil, nil) 26 | if err != nil { 27 | return report, err 28 | } 29 | defer ensureReaderClosed(serverResp) 30 | 31 | if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { 32 | return report, fmt.Errorf("Error retrieving network prune report: %v", err) 33 | } 34 | 35 | return report, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/reference/image_reference.go: -------------------------------------------------------------------------------- 1 | package reference 2 | 3 | import ( 4 | distreference "github.com/docker/distribution/reference" 5 | ) 6 | 7 | // Parse parses the given references and returns the repository and 8 | // tag (if present) from it. If there is an error during parsing, it will 9 | // return an error. 10 | func Parse(ref string) (string, string, error) { 11 | distributionRef, err := distreference.ParseNamed(ref) 12 | if err != nil { 13 | return "", "", err 14 | } 15 | 16 | tag := GetTagFromNamedRef(distributionRef) 17 | return distributionRef.Name(), tag, nil 18 | } 19 | 20 | // GetTagFromNamedRef returns a tag from the specified reference. 21 | // This function is necessary as long as the docker "server" api makes the distinction between repository 22 | // and tags. 23 | func GetTagFromNamedRef(ref distreference.Named) string { 24 | var tag string 25 | switch x := ref.(type) { 26 | case distreference.Digested: 27 | tag = x.Digest().String() 28 | case distreference.NamedTagged: 29 | tag = x.Tag() 30 | default: 31 | tag = "latest" 32 | } 33 | return tag 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_resize.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "github.com/docker/docker/api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ContainerResize changes the size of the tty for a container. 12 | func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error { 13 | return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) 14 | } 15 | 16 | // ContainerExecResize changes the size of the tty for an exec process running inside a container. 17 | func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error { 18 | return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) 19 | } 20 | 21 | func (cli *Client) resize(ctx context.Context, basePath string, height, width uint) error { 22 | query := url.Values{} 23 | query.Set("h", strconv.Itoa(int(height))) 24 | query.Set("w", strconv.Itoa(int(width))) 25 | 26 | resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) 27 | ensureReaderClosed(resp) 28 | return err 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_import.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | 9 | "github.com/docker/distribution/reference" 10 | "github.com/docker/docker/api/types" 11 | ) 12 | 13 | // ImageImport creates a new image based in the source options. 14 | // It returns the JSON content in the response body. 15 | func (cli *Client) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) { 16 | if ref != "" { 17 | //Check if the given image name can be resolved 18 | if _, err := reference.ParseNamed(ref); err != nil { 19 | return nil, err 20 | } 21 | } 22 | 23 | query := url.Values{} 24 | query.Set("fromSrc", source.SourceName) 25 | query.Set("repo", ref) 26 | query.Set("tag", options.Tag) 27 | query.Set("message", options.Message) 28 | for _, change := range options.Changes { 29 | query.Add("changes", change) 30 | } 31 | 32 | resp, err := cli.postRaw(ctx, "/images/create", query, source.Source, nil) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return resp.body, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | 9 | "github.com/docker/docker/api/types" 10 | "github.com/docker/docker/api/types/reference" 11 | ) 12 | 13 | // ImageCreate creates a new image based in the parent options. 14 | // It returns the JSON content in the response body. 15 | func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { 16 | repository, tag, err := reference.Parse(parentReference) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | query := url.Values{} 22 | query.Set("fromImage", repository) 23 | query.Set("tag", tag) 24 | resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) 25 | if err != nil { 26 | return nil, err 27 | } 28 | return resp.body, nil 29 | } 30 | 31 | func (cli *Client) tryImageCreate(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { 32 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 33 | return cli.post(ctx, "/images/create", query, nil, headers) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/image_summary.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // ImageSummary image summary 7 | // swagger:model ImageSummary 8 | type ImageSummary struct { 9 | 10 | // containers 11 | // Required: true 12 | Containers int64 `json:"Containers"` 13 | 14 | // created 15 | // Required: true 16 | Created int64 `json:"Created"` 17 | 18 | // Id 19 | // Required: true 20 | ID string `json:"Id"` 21 | 22 | // labels 23 | // Required: true 24 | Labels map[string]string `json:"Labels"` 25 | 26 | // parent Id 27 | // Required: true 28 | ParentID string `json:"ParentId"` 29 | 30 | // repo digests 31 | // Required: true 32 | RepoDigests []string `json:"RepoDigests"` 33 | 34 | // repo tags 35 | // Required: true 36 | RepoTags []string `json:"RepoTags"` 37 | 38 | // shared size 39 | // Required: true 40 | SharedSize int64 `json:"SharedSize"` 41 | 42 | // size 43 | // Required: true 44 | Size int64 `json:"Size"` 45 | 46 | // virtual size 47 | // Required: true 48 | VirtualSize int64 `json:"VirtualSize"` 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_attach.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerAttach attaches a connection to a container in the server. 11 | // It returns a types.HijackedConnection with the hijacked connection 12 | // and the a reader to get output. It's up to the called to close 13 | // the hijacked connection by calling types.HijackedResponse.Close. 14 | func (cli *Client) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) { 15 | query := url.Values{} 16 | if options.Stream { 17 | query.Set("stream", "1") 18 | } 19 | if options.Stdin { 20 | query.Set("stdin", "1") 21 | } 22 | if options.Stdout { 23 | query.Set("stdout", "1") 24 | } 25 | if options.Stderr { 26 | query.Set("stderr", "1") 27 | } 28 | if options.DetachKeys != "" { 29 | query.Set("detachKeys", options.DetachKeys) 30 | } 31 | if options.Logs { 32 | query.Set("logs", "1") 33 | } 34 | 35 | headers := map[string][]string{"Content-Type": {"text/plain"}} 36 | return cli.postHijacked(ctx, "/containers/"+container+"/attach", query, nil, headers) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2008 Dustin Sallings 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_tag.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | distreference "github.com/docker/distribution/reference" 7 | "github.com/docker/docker/api/types/reference" 8 | "github.com/pkg/errors" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // ImageTag tags an image in the docker host 13 | func (cli *Client) ImageTag(ctx context.Context, source, target string) error { 14 | if _, err := distreference.ParseNamed(source); err != nil { 15 | return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", source) 16 | } 17 | 18 | distributionRef, err := distreference.ParseNamed(target) 19 | if err != nil { 20 | return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", target) 21 | } 22 | 23 | if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical { 24 | return errors.New("refusing to create a tag with a digest reference") 25 | } 26 | 27 | tag := reference.GetTagFromNamedRef(distributionRef) 28 | 29 | query := url.Values{} 30 | query.Set("repo", distributionRef.Name()) 31 | query.Set("tag", tag) 32 | 33 | resp, err := cli.post(ctx, "/images/"+source+"/tag", query, nil, nil) 34 | ensureReaderClosed(resp) 35 | return err 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-units/duration.go: -------------------------------------------------------------------------------- 1 | // Package units provides helper function to parse and print size and time units 2 | // in human-readable format. 3 | package units 4 | 5 | import ( 6 | "fmt" 7 | "time" 8 | ) 9 | 10 | // HumanDuration returns a human-readable approximation of a duration 11 | // (eg. "About a minute", "4 hours ago", etc.). 12 | func HumanDuration(d time.Duration) string { 13 | if seconds := int(d.Seconds()); seconds < 1 { 14 | return "Less than a second" 15 | } else if seconds == 1 { 16 | return "1 second" 17 | } else if seconds < 60 { 18 | return fmt.Sprintf("%d seconds", seconds) 19 | } else if minutes := int(d.Minutes()); minutes == 1 { 20 | return "About a minute" 21 | } else if minutes < 46 { 22 | return fmt.Sprintf("%d minutes", minutes) 23 | } else if hours := int(d.Hours() + 0.5); hours == 1 { 24 | return "About an hour" 25 | } else if hours < 48 { 26 | return fmt.Sprintf("%d hours", hours) 27 | } else if hours < 24*7*2 { 28 | return fmt.Sprintf("%d days", hours/24) 29 | } else if hours < 24*30*2 { 30 | return fmt.Sprintf("%d weeks", hours/24/7) 31 | } else if hours < 24*365*2 { 32 | return fmt.Sprintf("%d months", hours/24/30) 33 | } 34 | return fmt.Sprintf("%d years", int(d.Hours())/24/365) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/service_update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strconv" 7 | 8 | "github.com/docker/docker/api/types" 9 | "github.com/docker/docker/api/types/swarm" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ServiceUpdate updates a Service. 14 | func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { 15 | var ( 16 | headers map[string][]string 17 | query = url.Values{} 18 | ) 19 | 20 | if options.EncodedRegistryAuth != "" { 21 | headers = map[string][]string{ 22 | "X-Registry-Auth": {options.EncodedRegistryAuth}, 23 | } 24 | } 25 | 26 | if options.RegistryAuthFrom != "" { 27 | query.Set("registryAuthFrom", options.RegistryAuthFrom) 28 | } 29 | 30 | query.Set("version", strconv.FormatUint(version.Index, 10)) 31 | 32 | var response types.ServiceUpdateResponse 33 | resp, err := cli.post(ctx, "/services/"+serviceID+"/update", query, service, headers) 34 | if err != nil { 35 | return response, err 36 | } 37 | 38 | err = json.NewDecoder(resp.body).Decode(&response) 39 | ensureReaderClosed(resp) 40 | return response, err 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/sockets.go: -------------------------------------------------------------------------------- 1 | // Package sockets provides helper functions to create and configure Unix or TCP sockets. 2 | package sockets 3 | 4 | import ( 5 | "errors" 6 | "net" 7 | "net/http" 8 | "time" 9 | ) 10 | 11 | // Why 32? See https://github.com/docker/docker/pull/8035. 12 | const defaultTimeout = 32 * time.Second 13 | 14 | // ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system. 15 | var ErrProtocolNotAvailable = errors.New("protocol not available") 16 | 17 | // ConfigureTransport configures the specified Transport according to the 18 | // specified proto and addr. 19 | // If the proto is unix (using a unix socket to communicate) or npipe the 20 | // compression is disabled. 21 | func ConfigureTransport(tr *http.Transport, proto, addr string) error { 22 | switch proto { 23 | case "unix": 24 | return configureUnixTransport(tr, proto, addr) 25 | case "npipe": 26 | return configureNpipeTransport(tr, proto, addr) 27 | default: 28 | tr.Proxy = http.ProxyFromEnvironment 29 | dialer, err := DialerFromEnvironment(&net.Dialer{ 30 | Timeout: defaultTimeout, 31 | }) 32 | if err != nil { 33 | return err 34 | } 35 | tr.Dial = dialer.Dial 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/volume_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // VolumeInspect returns the information about a specific volume in the docker host. 14 | func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) { 15 | volume, _, err := cli.VolumeInspectWithRaw(ctx, volumeID) 16 | return volume, err 17 | } 18 | 19 | // VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation 20 | func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) { 21 | var volume types.Volume 22 | resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil) 23 | if err != nil { 24 | if resp.statusCode == http.StatusNotFound { 25 | return volume, nil, volumeNotFoundError{volumeID} 26 | } 27 | return volume, nil, err 28 | } 29 | defer ensureReaderClosed(resp) 30 | 31 | body, err := ioutil.ReadAll(resp.body) 32 | if err != nil { 33 | return volume, nil, err 34 | } 35 | rdr := bytes.NewReader(body) 36 | err = json.NewDecoder(rdr).Decode(&volume) 37 | return volume, body, err 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone_go16.go: -------------------------------------------------------------------------------- 1 | // +build go1.6,!go1.7 2 | 3 | package tlsconfig 4 | 5 | import "crypto/tls" 6 | 7 | // Clone returns a clone of tls.Config. This function is provided for 8 | // compatibility for go1.6 that doesn't include this method in stdlib. 9 | func Clone(c *tls.Config) *tls.Config { 10 | return &tls.Config{ 11 | Rand: c.Rand, 12 | Time: c.Time, 13 | Certificates: c.Certificates, 14 | NameToCertificate: c.NameToCertificate, 15 | GetCertificate: c.GetCertificate, 16 | RootCAs: c.RootCAs, 17 | NextProtos: c.NextProtos, 18 | ServerName: c.ServerName, 19 | ClientAuth: c.ClientAuth, 20 | ClientCAs: c.ClientCAs, 21 | InsecureSkipVerify: c.InsecureSkipVerify, 22 | CipherSuites: c.CipherSuites, 23 | PreferServerCipherSuites: c.PreferServerCipherSuites, 24 | SessionTicketsDisabled: c.SessionTicketsDisabled, 25 | SessionTicketKey: c.SessionTicketKey, 26 | ClientSessionCache: c.ClientSessionCache, 27 | MinVersion: c.MinVersion, 28 | MaxVersion: c.MaxVersion, 29 | CurvePreferences: c.CurvePreferences, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/service_logs.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | "time" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/docker/api/types" 11 | timetypes "github.com/docker/docker/api/types/time" 12 | ) 13 | 14 | // ServiceLogs returns the logs generated by a service in an io.ReadCloser. 15 | // It's up to the caller to close the stream. 16 | func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) { 17 | query := url.Values{} 18 | if options.ShowStdout { 19 | query.Set("stdout", "1") 20 | } 21 | 22 | if options.ShowStderr { 23 | query.Set("stderr", "1") 24 | } 25 | 26 | if options.Since != "" { 27 | ts, err := timetypes.GetTimestamp(options.Since, time.Now()) 28 | if err != nil { 29 | return nil, err 30 | } 31 | query.Set("since", ts) 32 | } 33 | 34 | if options.Timestamps { 35 | query.Set("timestamps", "1") 36 | } 37 | 38 | if options.Details { 39 | query.Set("details", "1") 40 | } 41 | 42 | if options.Follow { 43 | query.Set("follow", "1") 44 | } 45 | query.Set("tail", options.Tail) 46 | 47 | resp, err := cli.get(ctx, "/services/"+serviceID+"/logs", query, nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return resp.body, nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_logs.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | "time" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/docker/api/types" 11 | timetypes "github.com/docker/docker/api/types/time" 12 | ) 13 | 14 | // ContainerLogs returns the logs generated by a container in an io.ReadCloser. 15 | // It's up to the caller to close the stream. 16 | func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) { 17 | query := url.Values{} 18 | if options.ShowStdout { 19 | query.Set("stdout", "1") 20 | } 21 | 22 | if options.ShowStderr { 23 | query.Set("stderr", "1") 24 | } 25 | 26 | if options.Since != "" { 27 | ts, err := timetypes.GetTimestamp(options.Since, time.Now()) 28 | if err != nil { 29 | return nil, err 30 | } 31 | query.Set("since", ts) 32 | } 33 | 34 | if options.Timestamps { 35 | query.Set("timestamps", "1") 36 | } 37 | 38 | if options.Details { 39 | query.Set("details", "1") 40 | } 41 | 42 | if options.Follow { 43 | query.Set("follow", "1") 44 | } 45 | query.Set("tail", options.Tail) 46 | 47 | resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return resp.body, nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | return logger.WriterLevel(InfoLevel) 11 | } 12 | 13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { 14 | reader, writer := io.Pipe() 15 | 16 | var printFunc func(args ...interface{}) 17 | switch level { 18 | case DebugLevel: 19 | printFunc = logger.Debug 20 | case InfoLevel: 21 | printFunc = logger.Info 22 | case WarnLevel: 23 | printFunc = logger.Warn 24 | case ErrorLevel: 25 | printFunc = logger.Error 26 | case FatalLevel: 27 | printFunc = logger.Fatal 28 | case PanicLevel: 29 | printFunc = logger.Panic 30 | default: 31 | printFunc = logger.Print 32 | } 33 | 34 | go logger.writerScanner(reader, printFunc) 35 | runtime.SetFinalizer(writer, writerFinalizer) 36 | 37 | return writer 38 | } 39 | 40 | func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { 41 | scanner := bufio.NewScanner(reader) 42 | for scanner.Scan() { 43 | printFunc(scanner.Text()) 44 | } 45 | if err := scanner.Err(); err != nil { 46 | logger.Errorf("Error while reading from Writer: %s", err) 47 | } 48 | reader.Close() 49 | } 50 | 51 | func writerFinalizer(writer *io.PipeWriter) { 52 | writer.Close() 53 | } 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strconv" 7 | 8 | "github.com/docker/docker/api/types" 9 | "github.com/docker/docker/api/types/filters" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ContainerList returns the list of containers in the docker host. 14 | func (cli *Client) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { 15 | query := url.Values{} 16 | 17 | if options.All { 18 | query.Set("all", "1") 19 | } 20 | 21 | if options.Limit != -1 { 22 | query.Set("limit", strconv.Itoa(options.Limit)) 23 | } 24 | 25 | if options.Since != "" { 26 | query.Set("since", options.Since) 27 | } 28 | 29 | if options.Before != "" { 30 | query.Set("before", options.Before) 31 | } 32 | 33 | if options.Size { 34 | query.Set("size", "1") 35 | } 36 | 37 | if options.Filters.Len() > 0 { 38 | filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) 39 | 40 | if err != nil { 41 | return nil, err 42 | } 43 | 44 | query.Set("filters", filterJSON) 45 | } 46 | 47 | resp, err := cli.get(ctx, "/containers/json", query, nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | var containers []types.Container 53 | err = json.NewDecoder(resp.body).Decode(&containers) 54 | ensureReaderClosed(resp) 55 | return containers, err 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/network_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | 9 | "github.com/docker/docker/api/types" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // NetworkInspect returns the information for a specific network configured in the docker host. 14 | func (cli *Client) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) { 15 | networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID) 16 | return networkResource, err 17 | } 18 | 19 | // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation. 20 | func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string) (types.NetworkResource, []byte, error) { 21 | var networkResource types.NetworkResource 22 | resp, err := cli.get(ctx, "/networks/"+networkID, nil, nil) 23 | if err != nil { 24 | if resp.statusCode == http.StatusNotFound { 25 | return networkResource, nil, networkNotFoundError{networkID} 26 | } 27 | return networkResource, nil, err 28 | } 29 | defer ensureReaderClosed(resp) 30 | 31 | body, err := ioutil.ReadAll(resp.body) 32 | if err != nil { 33 | return networkResource, nil, err 34 | } 35 | rdr := bytes.NewReader(body) 36 | err = json.NewDecoder(rdr).Decode(&networkResource) 37 | return networkResource, body, err 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/proxy.go: -------------------------------------------------------------------------------- 1 | package sockets 2 | 3 | import ( 4 | "net" 5 | "net/url" 6 | "os" 7 | "strings" 8 | 9 | "golang.org/x/net/proxy" 10 | ) 11 | 12 | // GetProxyEnv allows access to the uppercase and the lowercase forms of 13 | // proxy-related variables. See the Go specification for details on these 14 | // variables. https://golang.org/pkg/net/http/ 15 | func GetProxyEnv(key string) string { 16 | proxyValue := os.Getenv(strings.ToUpper(key)) 17 | if proxyValue == "" { 18 | return os.Getenv(strings.ToLower(key)) 19 | } 20 | return proxyValue 21 | } 22 | 23 | // DialerFromEnvironment takes in a "direct" *net.Dialer and returns a 24 | // proxy.Dialer which will route the connections through the proxy using the 25 | // given dialer. 26 | func DialerFromEnvironment(direct *net.Dialer) (proxy.Dialer, error) { 27 | allProxy := GetProxyEnv("all_proxy") 28 | if len(allProxy) == 0 { 29 | return direct, nil 30 | } 31 | 32 | proxyURL, err := url.Parse(allProxy) 33 | if err != nil { 34 | return direct, err 35 | } 36 | 37 | proxyFromURL, err := proxy.FromURL(proxyURL, direct) 38 | if err != nil { 39 | return direct, err 40 | } 41 | 42 | noProxy := GetProxyEnv("no_proxy") 43 | if len(noProxy) == 0 { 44 | return proxyFromURL, nil 45 | } 46 | 47 | perHost := proxy.NewPerHost(proxyFromURL, direct) 48 | perHost.AddFromString(noProxy) 49 | 50 | return perHost, nil 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/docker/api/types" 8 | "github.com/docker/docker/api/types/filters" 9 | "github.com/docker/docker/api/types/versions" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ImageList returns a list of images in the docker host. 14 | func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) { 15 | var images []types.ImageSummary 16 | query := url.Values{} 17 | 18 | optionFilters := options.Filters 19 | referenceFilters := optionFilters.Get("reference") 20 | if versions.LessThan(cli.version, "1.25") && len(referenceFilters) > 0 { 21 | query.Set("filter", referenceFilters[0]) 22 | for _, filterValue := range referenceFilters { 23 | optionFilters.Del("reference", filterValue) 24 | } 25 | } 26 | if optionFilters.Len() > 0 { 27 | filterJSON, err := filters.ToParamWithVersion(cli.version, optionFilters) 28 | if err != nil { 29 | return images, err 30 | } 31 | query.Set("filters", filterJSON) 32 | } 33 | if options.All { 34 | query.Set("all", "1") 35 | } 36 | 37 | serverResp, err := cli.get(ctx, "/images/json", query, nil) 38 | if err != nil { 39 | return images, err 40 | } 41 | 42 | err = json.NewDecoder(serverResp.body).Decode(&images) 43 | ensureReaderClosed(serverResp) 44 | return images, err 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/tlsconfig/tlsconfig_clone_go17.go: -------------------------------------------------------------------------------- 1 | // +build go1.7,!go1.8 2 | 3 | package tlsconfig 4 | 5 | import "crypto/tls" 6 | 7 | // Clone returns a clone of tls.Config. This function is provided for 8 | // compatibility for go1.7 that doesn't include this method in stdlib. 9 | func Clone(c *tls.Config) *tls.Config { 10 | return &tls.Config{ 11 | Rand: c.Rand, 12 | Time: c.Time, 13 | Certificates: c.Certificates, 14 | NameToCertificate: c.NameToCertificate, 15 | GetCertificate: c.GetCertificate, 16 | RootCAs: c.RootCAs, 17 | NextProtos: c.NextProtos, 18 | ServerName: c.ServerName, 19 | ClientAuth: c.ClientAuth, 20 | ClientCAs: c.ClientCAs, 21 | InsecureSkipVerify: c.InsecureSkipVerify, 22 | CipherSuites: c.CipherSuites, 23 | PreferServerCipherSuites: c.PreferServerCipherSuites, 24 | SessionTicketsDisabled: c.SessionTicketsDisabled, 25 | SessionTicketKey: c.SessionTicketKey, 26 | ClientSessionCache: c.ClientSessionCache, 27 | MinVersion: c.MinVersion, 28 | MaxVersion: c.MaxVersion, 29 | CurvePreferences: c.CurvePreferences, 30 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, 31 | Renegotiation: c.Renegotiation, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### buildcache 2 | 3 | Store Docker buildcache to a separate file that can be reapplied after `docker pull`. 4 | 5 | #### install 6 | 7 | `go get github.com/tonistiigi/buildcache/cmd/buildcache` 8 | 9 | #### usage 10 | 11 | After building your image run. 12 | 13 | ``` 14 | buildcache save -o cache.tgz imagename 15 | ``` 16 | 17 | This will create a small file `cache.tgz` that contains all known build cache for the image. 18 | 19 | When you want to restore it in another machine run: 20 | 21 | ``` 22 | docker pull imagename 23 | docker load -i cache.tgz 24 | ``` 25 | 26 | #### on problems 27 | 28 | Build cache can only be applied if the pulled image is the same that was built. Easy way to check that is to check if the ID of the image that was first built is the same that you got after `docker pull` in another machine. 29 | 30 | If `docker load` succeeds but cache still isn't being used in another machine try running `docker history id-of-pulled-image` and `docker history id-of-built-image` and compare the results to see where you got a cache miss. 31 | 32 | #### compatibility 33 | 34 | Buildcache works with Docker v1.12 using only the remote API. To use buildcache in Docker v1.11 it needs to access the Docker storage directory directly. Use `-g` options to specify directory other than `/var/lib/docker`. Eariler Docker versions are not supported. 35 | 36 | **Note**: Docker 1.13 added support for `--cache-from` flag to the build command, replacing the need for this tool. 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/events/events.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | const ( 4 | // ContainerEventType is the event type that containers generate 5 | ContainerEventType = "container" 6 | // DaemonEventType is the event type that daemon generate 7 | DaemonEventType = "daemon" 8 | // ImageEventType is the event type that images generate 9 | ImageEventType = "image" 10 | // NetworkEventType is the event type that networks generate 11 | NetworkEventType = "network" 12 | // PluginEventType is the event type that plugins generate 13 | PluginEventType = "plugin" 14 | // VolumeEventType is the event type that volumes generate 15 | VolumeEventType = "volume" 16 | ) 17 | 18 | // Actor describes something that generates events, 19 | // like a container, or a network, or a volume. 20 | // It has a defined name and a set or attributes. 21 | // The container attributes are its labels, other actors 22 | // can generate these attributes from other properties. 23 | type Actor struct { 24 | ID string 25 | Attributes map[string]string 26 | } 27 | 28 | // Message represents the information an event contains 29 | type Message struct { 30 | // Deprecated information from JSONMessage. 31 | // With data only in container events. 32 | Status string `json:"status,omitempty"` 33 | ID string `json:"id,omitempty"` 34 | From string `json:"from,omitempty"` 35 | 36 | Type string 37 | Action string 38 | Actor Actor 39 | 40 | Time int64 `json:"time,omitempty"` 41 | TimeNano int64 `json:"timeNano,omitempty"` 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | if t, ok := data["time"]; ok { 35 | data["fields.time"] = t 36 | } 37 | 38 | if m, ok := data["msg"]; ok { 39 | data["fields.msg"] = m 40 | } 41 | 42 | if l, ok := data["level"]; ok { 43 | data["fields.level"] = l 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_pull.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "net/url" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/docker/api/types" 11 | "github.com/docker/docker/api/types/reference" 12 | ) 13 | 14 | // ImagePull requests the docker host to pull an image from a remote registry. 15 | // It executes the privileged function if the operation is unauthorized 16 | // and it tries one more time. 17 | // It's up to the caller to handle the io.ReadCloser and close it properly. 18 | // 19 | // FIXME(vdemeester): there is currently used in a few way in docker/docker 20 | // - if not in trusted content, ref is used to pass the whole reference, and tag is empty 21 | // - if in trusted content, ref is used to pass the reference name, and tag for the digest 22 | func (cli *Client) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) { 23 | repository, tag, err := reference.Parse(ref) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | query := url.Values{} 29 | query.Set("fromImage", repository) 30 | if tag != "" && !options.All { 31 | query.Set("tag", tag) 32 | } 33 | 34 | resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) 35 | if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil { 36 | newAuthHeader, privilegeErr := options.PrivilegeFunc() 37 | if privilegeErr != nil { 38 | return nil, privilegeErr 39 | } 40 | resp, err = cli.tryImageCreate(ctx, query, newAuthHeader) 41 | } 42 | if err != nil { 43 | return nil, err 44 | } 45 | return resp.body, nil 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/versions/compare.go: -------------------------------------------------------------------------------- 1 | package versions 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | ) 7 | 8 | // compare compares two version strings 9 | // returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise. 10 | func compare(v1, v2 string) int { 11 | var ( 12 | currTab = strings.Split(v1, ".") 13 | otherTab = strings.Split(v2, ".") 14 | ) 15 | 16 | max := len(currTab) 17 | if len(otherTab) > max { 18 | max = len(otherTab) 19 | } 20 | for i := 0; i < max; i++ { 21 | var currInt, otherInt int 22 | 23 | if len(currTab) > i { 24 | currInt, _ = strconv.Atoi(currTab[i]) 25 | } 26 | if len(otherTab) > i { 27 | otherInt, _ = strconv.Atoi(otherTab[i]) 28 | } 29 | if currInt > otherInt { 30 | return 1 31 | } 32 | if otherInt > currInt { 33 | return -1 34 | } 35 | } 36 | return 0 37 | } 38 | 39 | // LessThan checks if a version is less than another 40 | func LessThan(v, other string) bool { 41 | return compare(v, other) == -1 42 | } 43 | 44 | // LessThanOrEqualTo checks if a version is less than or equal to another 45 | func LessThanOrEqualTo(v, other string) bool { 46 | return compare(v, other) <= 0 47 | } 48 | 49 | // GreaterThan checks if a version is greater than another 50 | func GreaterThan(v, other string) bool { 51 | return compare(v, other) == 1 52 | } 53 | 54 | // GreaterThanOrEqualTo checks if a version is greater than or equal to another 55 | func GreaterThanOrEqualTo(v, other string) bool { 56 | return compare(v, other) >= 0 57 | } 58 | 59 | // Equal checks if a version is equal to another 60 | func Equal(v, other string) bool { 61 | return compare(v, other) == 0 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Alex Ogier. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_commit.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "net/url" 7 | 8 | distreference "github.com/docker/distribution/reference" 9 | "github.com/docker/docker/api/types" 10 | "github.com/docker/docker/api/types/reference" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // ContainerCommit applies changes into a container and creates a new tagged image. 15 | func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) { 16 | var repository, tag string 17 | if options.Reference != "" { 18 | distributionRef, err := distreference.ParseNamed(options.Reference) 19 | if err != nil { 20 | return types.IDResponse{}, err 21 | } 22 | 23 | if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical { 24 | return types.IDResponse{}, errors.New("refusing to create a tag with a digest reference") 25 | } 26 | 27 | tag = reference.GetTagFromNamedRef(distributionRef) 28 | repository = distributionRef.Name() 29 | } 30 | 31 | query := url.Values{} 32 | query.Set("container", container) 33 | query.Set("repo", repository) 34 | query.Set("tag", tag) 35 | query.Set("comment", options.Comment) 36 | query.Set("author", options.Author) 37 | for _, change := range options.Changes { 38 | query.Add("changes", change) 39 | } 40 | if options.Pause != true { 41 | query.Set("pause", "0") 42 | } 43 | 44 | var response types.IDResponse 45 | resp, err := cli.post(ctx, "/commit", query, options.Config, nil) 46 | if err != nil { 47 | return response, err 48 | } 49 | 50 | err = json.NewDecoder(resp.body).Decode(&response) 51 | ensureReaderClosed(resp) 52 | return response, err 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/nat/parse.go: -------------------------------------------------------------------------------- 1 | package nat 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // PartParser parses and validates the specified string (data) using the specified template 10 | // e.g. ip:public:private -> 192.168.0.1:80:8000 11 | // DEPRECATED: do not use, this function may be removed in a future version 12 | func PartParser(template, data string) (map[string]string, error) { 13 | // ip:public:private 14 | var ( 15 | templateParts = strings.Split(template, ":") 16 | parts = strings.Split(data, ":") 17 | out = make(map[string]string, len(templateParts)) 18 | ) 19 | if len(parts) != len(templateParts) { 20 | return nil, fmt.Errorf("Invalid format to parse. %s should match template %s", data, template) 21 | } 22 | 23 | for i, t := range templateParts { 24 | value := "" 25 | if len(parts) > i { 26 | value = parts[i] 27 | } 28 | out[t] = value 29 | } 30 | return out, nil 31 | } 32 | 33 | // ParsePortRange parses and validates the specified string as a port-range (8000-9000) 34 | func ParsePortRange(ports string) (uint64, uint64, error) { 35 | if ports == "" { 36 | return 0, 0, fmt.Errorf("Empty string specified for ports.") 37 | } 38 | if !strings.Contains(ports, "-") { 39 | start, err := strconv.ParseUint(ports, 10, 16) 40 | end := start 41 | return start, end, err 42 | } 43 | 44 | parts := strings.Split(ports, "-") 45 | start, err := strconv.ParseUint(parts[0], 10, 16) 46 | if err != nil { 47 | return 0, 0, err 48 | } 49 | end, err := strconv.ParseUint(parts[1], 10, 16) 50 | if err != nil { 51 | return 0, 0, err 52 | } 53 | if end < start { 54 | return 0, 0, fmt.Errorf("Invalid range specified for the Port: %s", ports) 55 | } 56 | return start, end, nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_search.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/http" 7 | "net/url" 8 | 9 | "github.com/docker/docker/api/types" 10 | "github.com/docker/docker/api/types/filters" 11 | "github.com/docker/docker/api/types/registry" 12 | "golang.org/x/net/context" 13 | ) 14 | 15 | // ImageSearch makes the docker host to search by a term in a remote registry. 16 | // The list of results is not sorted in any fashion. 17 | func (cli *Client) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) { 18 | var results []registry.SearchResult 19 | query := url.Values{} 20 | query.Set("term", term) 21 | query.Set("limit", fmt.Sprintf("%d", options.Limit)) 22 | 23 | if options.Filters.Len() > 0 { 24 | filterJSON, err := filters.ToParam(options.Filters) 25 | if err != nil { 26 | return results, err 27 | } 28 | query.Set("filters", filterJSON) 29 | } 30 | 31 | resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth) 32 | if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil { 33 | newAuthHeader, privilegeErr := options.PrivilegeFunc() 34 | if privilegeErr != nil { 35 | return results, privilegeErr 36 | } 37 | resp, err = cli.tryImageSearch(ctx, query, newAuthHeader) 38 | } 39 | if err != nil { 40 | return results, err 41 | } 42 | 43 | err = json.NewDecoder(resp.body).Decode(&results) 44 | ensureReaderClosed(resp) 45 | return results, err 46 | } 47 | 48 | func (cli *Client) tryImageSearch(ctx context.Context, query url.Values, registryAuth string) (serverResponse, error) { 49 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 50 | return cli.get(ctx, "/images/search", query, headers) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/go-digest/doc.go: -------------------------------------------------------------------------------- 1 | // Package digest provides a generalized type to opaquely represent message 2 | // digests and their operations within the registry. The Digest type is 3 | // designed to serve as a flexible identifier in a content-addressable system. 4 | // More importantly, it provides tools and wrappers to work with 5 | // hash.Hash-based digests with little effort. 6 | // 7 | // Basics 8 | // 9 | // The format of a digest is simply a string with two parts, dubbed the 10 | // "algorithm" and the "digest", separated by a colon: 11 | // 12 | // : 13 | // 14 | // An example of a sha256 digest representation follows: 15 | // 16 | // sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc 17 | // 18 | // In this case, the string "sha256" is the algorithm and the hex bytes are 19 | // the "digest". 20 | // 21 | // Because the Digest type is simply a string, once a valid Digest is 22 | // obtained, comparisons are cheap, quick and simple to express with the 23 | // standard equality operator. 24 | // 25 | // Verification 26 | // 27 | // The main benefit of using the Digest type is simple verification against a 28 | // given digest. The Verifier interface, modeled after the stdlib hash.Hash 29 | // interface, provides a common write sink for digest verification. After 30 | // writing is complete, calling the Verifier.Verified method will indicate 31 | // whether or not the stream of bytes matches the target digest. 32 | // 33 | // Missing Features 34 | // 35 | // In addition to the above, we intend to add the following features to this 36 | // package: 37 | // 38 | // 1. A Digester type that supports write sink digest calculation. 39 | // 40 | // 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry. 41 | // 42 | package digest 43 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/digest/doc.go: -------------------------------------------------------------------------------- 1 | // Package digest provides a generalized type to opaquely represent message 2 | // digests and their operations within the registry. The Digest type is 3 | // designed to serve as a flexible identifier in a content-addressable system. 4 | // More importantly, it provides tools and wrappers to work with 5 | // hash.Hash-based digests with little effort. 6 | // 7 | // Basics 8 | // 9 | // The format of a digest is simply a string with two parts, dubbed the 10 | // "algorithm" and the "digest", separated by a colon: 11 | // 12 | // : 13 | // 14 | // An example of a sha256 digest representation follows: 15 | // 16 | // sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc 17 | // 18 | // In this case, the string "sha256" is the algorithm and the hex bytes are 19 | // the "digest". 20 | // 21 | // Because the Digest type is simply a string, once a valid Digest is 22 | // obtained, comparisons are cheap, quick and simple to express with the 23 | // standard equality operator. 24 | // 25 | // Verification 26 | // 27 | // The main benefit of using the Digest type is simple verification against a 28 | // given digest. The Verifier interface, modeled after the stdlib hash.Hash 29 | // interface, provides a common write sink for digest verification. After 30 | // writing is complete, calling the Verifier.Verified method will indicate 31 | // whether or not the stream of bytes matches the target digest. 32 | // 33 | // Missing Features 34 | // 35 | // In addition to the above, we intend to add the following features to this 36 | // package: 37 | // 38 | // 1. A Digester type that supports write sink digest calculation. 39 | // 40 | // 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry. 41 | // 42 | package digest 43 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | "net/url" 9 | 10 | "github.com/docker/docker/api/types" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // ContainerInspect returns the container information. 15 | func (cli *Client) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { 16 | serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", nil, nil) 17 | if err != nil { 18 | if serverResp.statusCode == http.StatusNotFound { 19 | return types.ContainerJSON{}, containerNotFoundError{containerID} 20 | } 21 | return types.ContainerJSON{}, err 22 | } 23 | 24 | var response types.ContainerJSON 25 | err = json.NewDecoder(serverResp.body).Decode(&response) 26 | ensureReaderClosed(serverResp) 27 | return response, err 28 | } 29 | 30 | // ContainerInspectWithRaw returns the container information and its raw representation. 31 | func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (types.ContainerJSON, []byte, error) { 32 | query := url.Values{} 33 | if getSize { 34 | query.Set("size", "1") 35 | } 36 | serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", query, nil) 37 | if err != nil { 38 | if serverResp.statusCode == http.StatusNotFound { 39 | return types.ContainerJSON{}, nil, containerNotFoundError{containerID} 40 | } 41 | return types.ContainerJSON{}, nil, err 42 | } 43 | defer ensureReaderClosed(serverResp) 44 | 45 | body, err := ioutil.ReadAll(serverResp.body) 46 | if err != nil { 47 | return types.ContainerJSON{}, nil, err 48 | } 49 | 50 | var response types.ContainerJSON 51 | rdr := bytes.NewReader(body) 52 | err = json.NewDecoder(rdr).Decode(&response) 53 | return response, body, err 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/plugin_responses.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | // PluginsListResponse contains the response for the Engine API 9 | type PluginsListResponse []*Plugin 10 | 11 | const ( 12 | authzDriver = "AuthzDriver" 13 | graphDriver = "GraphDriver" 14 | ipamDriver = "IpamDriver" 15 | networkDriver = "NetworkDriver" 16 | volumeDriver = "VolumeDriver" 17 | ) 18 | 19 | // UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType 20 | func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error { 21 | versionIndex := len(p) 22 | prefixIndex := 0 23 | if len(p) < 2 || p[0] != '"' || p[len(p)-1] != '"' { 24 | return fmt.Errorf("%q is not a plugin interface type", p) 25 | } 26 | p = p[1 : len(p)-1] 27 | loop: 28 | for i, b := range p { 29 | switch b { 30 | case '.': 31 | prefixIndex = i 32 | case '/': 33 | versionIndex = i 34 | break loop 35 | } 36 | } 37 | t.Prefix = string(p[:prefixIndex]) 38 | t.Capability = string(p[prefixIndex+1 : versionIndex]) 39 | if versionIndex < len(p) { 40 | t.Version = string(p[versionIndex+1:]) 41 | } 42 | return nil 43 | } 44 | 45 | // MarshalJSON implements json.Marshaler for PluginInterfaceType 46 | func (t *PluginInterfaceType) MarshalJSON() ([]byte, error) { 47 | return json.Marshal(t.String()) 48 | } 49 | 50 | // String implements fmt.Stringer for PluginInterfaceType 51 | func (t PluginInterfaceType) String() string { 52 | return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version) 53 | } 54 | 55 | // PluginPrivilege describes a permission the user has to accept 56 | // upon installing a plugin. 57 | type PluginPrivilege struct { 58 | Name string 59 | Description string 60 | Value []string 61 | } 62 | 63 | // PluginPrivileges is a list of PluginPrivilege 64 | type PluginPrivileges []PluginPrivilege 65 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/volume.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // This file was generated by the swagger tool. 4 | // Editing this file might prove futile when you re-run the swagger generate command 5 | 6 | // Volume volume 7 | // swagger:model Volume 8 | type Volume struct { 9 | 10 | // Name of the volume driver used by the volume. 11 | // Required: true 12 | Driver string `json:"Driver"` 13 | 14 | // User-defined key/value metadata. 15 | // Required: true 16 | Labels map[string]string `json:"Labels"` 17 | 18 | // Mount path of the volume on the host. 19 | // Required: true 20 | Mountpoint string `json:"Mountpoint"` 21 | 22 | // Name of the volume. 23 | // Required: true 24 | Name string `json:"Name"` 25 | 26 | // The driver specific options used when creating the volume. 27 | // Required: true 28 | Options map[string]string `json:"Options"` 29 | 30 | // The level at which the volume exists. Either `global` for cluster-wide, or `local` for machine level. 31 | // Required: true 32 | Scope string `json:"Scope"` 33 | 34 | // Low-level details about the volume, provided by the volume driver. 35 | // Details are returned as a map with key/value pairs: 36 | // `{"key":"value","key2":"value2"}`. 37 | // 38 | // The `Status` field is optional, and is omitted if the volume driver 39 | // does not support this feature. 40 | // 41 | Status map[string]interface{} `json:"Status,omitempty"` 42 | 43 | // usage data 44 | UsageData *VolumeUsageData `json:"UsageData,omitempty"` 45 | } 46 | 47 | // VolumeUsageData volume usage data 48 | // swagger:model VolumeUsageData 49 | type VolumeUsageData struct { 50 | 51 | // The number of containers referencing this volume. 52 | // Required: true 53 | RefCount int64 `json:"RefCount"` 54 | 55 | // The disk space used by the volume (local driver only) 56 | // Required: true 57 | Size int64 `json:"Size"` 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/image_push.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "net/http" 7 | "net/url" 8 | 9 | "golang.org/x/net/context" 10 | 11 | distreference "github.com/docker/distribution/reference" 12 | "github.com/docker/docker/api/types" 13 | ) 14 | 15 | // ImagePush requests the docker host to push an image to a remote registry. 16 | // It executes the privileged function if the operation is unauthorized 17 | // and it tries one more time. 18 | // It's up to the caller to handle the io.ReadCloser and close it properly. 19 | func (cli *Client) ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { 20 | distributionRef, err := distreference.ParseNamed(ref) 21 | if err != nil { 22 | return nil, err 23 | } 24 | 25 | if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical { 26 | return nil, errors.New("cannot push a digest reference") 27 | } 28 | 29 | var tag = "" 30 | if nameTaggedRef, isNamedTagged := distributionRef.(distreference.NamedTagged); isNamedTagged { 31 | tag = nameTaggedRef.Tag() 32 | } 33 | 34 | query := url.Values{} 35 | query.Set("tag", tag) 36 | 37 | resp, err := cli.tryImagePush(ctx, distributionRef.Name(), query, options.RegistryAuth) 38 | if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil { 39 | newAuthHeader, privilegeErr := options.PrivilegeFunc() 40 | if privilegeErr != nil { 41 | return nil, privilegeErr 42 | } 43 | resp, err = cli.tryImagePush(ctx, distributionRef.Name(), query, newAuthHeader) 44 | } 45 | if err != nil { 46 | return nil, err 47 | } 48 | return resp.body, nil 49 | } 50 | 51 | func (cli *Client) tryImagePush(ctx context.Context, imageID string, query url.Values, registryAuth string) (serverResponse, error) { 52 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 53 | return cli.post(ctx, "/images/"+imageID+"/push", query, nil, headers) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/network/network.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | // Address represents an IP address 4 | type Address struct { 5 | Addr string 6 | PrefixLen int 7 | } 8 | 9 | // IPAM represents IP Address Management 10 | type IPAM struct { 11 | Driver string 12 | Options map[string]string //Per network IPAM driver options 13 | Config []IPAMConfig 14 | } 15 | 16 | // IPAMConfig represents IPAM configurations 17 | type IPAMConfig struct { 18 | Subnet string `json:",omitempty"` 19 | IPRange string `json:",omitempty"` 20 | Gateway string `json:",omitempty"` 21 | AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` 22 | } 23 | 24 | // EndpointIPAMConfig represents IPAM configurations for the endpoint 25 | type EndpointIPAMConfig struct { 26 | IPv4Address string `json:",omitempty"` 27 | IPv6Address string `json:",omitempty"` 28 | LinkLocalIPs []string `json:",omitempty"` 29 | } 30 | 31 | // PeerInfo represents one peer of an overlay network 32 | type PeerInfo struct { 33 | Name string 34 | IP string 35 | } 36 | 37 | // EndpointSettings stores the network endpoint details 38 | type EndpointSettings struct { 39 | // Configurations 40 | IPAMConfig *EndpointIPAMConfig 41 | Links []string 42 | Aliases []string 43 | // Operational data 44 | NetworkID string 45 | EndpointID string 46 | Gateway string 47 | IPAddress string 48 | IPPrefixLen int 49 | IPv6Gateway string 50 | GlobalIPv6Address string 51 | GlobalIPv6PrefixLen int 52 | MacAddress string 53 | } 54 | 55 | // NetworkingConfig represents the container's networking configuration for each of its interfaces 56 | // Carries the networking configs specified in the `docker run` and `docker network connect` commands 57 | type NetworkingConfig struct { 58 | EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strings" 7 | 8 | "github.com/docker/docker/api/types/container" 9 | "github.com/docker/docker/api/types/network" 10 | "github.com/docker/docker/api/types/versions" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | type configWrapper struct { 15 | *container.Config 16 | HostConfig *container.HostConfig 17 | NetworkingConfig *network.NetworkingConfig 18 | } 19 | 20 | // ContainerCreate creates a new container based in the given configuration. 21 | // It can be associated with a name, but it's not mandatory. 22 | func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) { 23 | var response container.ContainerCreateCreatedBody 24 | 25 | if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil { 26 | return response, err 27 | } 28 | 29 | // When using API 1.24 and under, the client is responsible for removing the container 30 | if hostConfig != nil && versions.LessThan(cli.ClientVersion(), "1.25") { 31 | hostConfig.AutoRemove = false 32 | } 33 | 34 | query := url.Values{} 35 | if containerName != "" { 36 | query.Set("name", containerName) 37 | } 38 | 39 | body := configWrapper{ 40 | Config: config, 41 | HostConfig: hostConfig, 42 | NetworkingConfig: networkingConfig, 43 | } 44 | 45 | serverResp, err := cli.post(ctx, "/containers/create", query, body, nil) 46 | if err != nil { 47 | if serverResp.statusCode == 404 && strings.Contains(err.Error(), "No such image") { 48 | return response, imageNotFoundError{config.Image} 49 | } 50 | return response, err 51 | } 52 | 53 | err = json.NewDecoder(serverResp.body).Decode(&response) 54 | ensureReaderClosed(serverResp) 55 | return response, err 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type fieldKey string 9 | type FieldMap map[fieldKey]string 10 | 11 | const ( 12 | FieldKeyMsg = "msg" 13 | FieldKeyLevel = "level" 14 | FieldKeyTime = "time" 15 | ) 16 | 17 | func (f FieldMap) resolve(key fieldKey) string { 18 | if k, ok := f[key]; ok { 19 | return k 20 | } 21 | 22 | return string(key) 23 | } 24 | 25 | type JSONFormatter struct { 26 | // TimestampFormat sets the format used for marshaling timestamps. 27 | TimestampFormat string 28 | 29 | // DisableTimestamp allows disabling automatic timestamps in output 30 | DisableTimestamp bool 31 | 32 | // FieldMap allows users to customize the names of keys for various fields. 33 | // As an example: 34 | // formatter := &JSONFormatter{ 35 | // FieldMap: FieldMap{ 36 | // FieldKeyTime: "@timestamp", 37 | // FieldKeyLevel: "@level", 38 | // FieldKeyLevel: "@message", 39 | // }, 40 | // } 41 | FieldMap FieldMap 42 | } 43 | 44 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 45 | data := make(Fields, len(entry.Data)+3) 46 | for k, v := range entry.Data { 47 | switch v := v.(type) { 48 | case error: 49 | // Otherwise errors are ignored by `encoding/json` 50 | // https://github.com/Sirupsen/logrus/issues/137 51 | data[k] = v.Error() 52 | default: 53 | data[k] = v 54 | } 55 | } 56 | prefixFieldClashes(data) 57 | 58 | timestampFormat := f.TimestampFormat 59 | if timestampFormat == "" { 60 | timestampFormat = DefaultTimestampFormat 61 | } 62 | 63 | if !f.DisableTimestamp { 64 | data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) 65 | } 66 | data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message 67 | data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() 68 | 69 | serialized, err := json.Marshal(data) 70 | if err != nil { 71 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 72 | } 73 | return append(serialized, '\n'), nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build solaris 6 | 7 | package terminal // import "golang.org/x/crypto/ssh/terminal" 8 | 9 | import ( 10 | "golang.org/x/sys/unix" 11 | "io" 12 | "syscall" 13 | ) 14 | 15 | // State contains the state of a terminal. 16 | type State struct { 17 | termios syscall.Termios 18 | } 19 | 20 | // IsTerminal returns true if the given file descriptor is a terminal. 21 | func IsTerminal(fd int) bool { 22 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 23 | var termio unix.Termio 24 | err := unix.IoctlSetTermio(fd, unix.TCGETA, &termio) 25 | return err == nil 26 | } 27 | 28 | // ReadPassword reads a line of input from a terminal without local echo. This 29 | // is commonly used for inputting passwords and other sensitive data. The slice 30 | // returned does not include the \n. 31 | func ReadPassword(fd int) ([]byte, error) { 32 | // see also: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libast/common/uwin/getpass.c 33 | val, err := unix.IoctlGetTermios(fd, unix.TCGETS) 34 | if err != nil { 35 | return nil, err 36 | } 37 | oldState := *val 38 | 39 | newState := oldState 40 | newState.Lflag &^= syscall.ECHO 41 | newState.Lflag |= syscall.ICANON | syscall.ISIG 42 | newState.Iflag |= syscall.ICRNL 43 | err = unix.IoctlSetTermios(fd, unix.TCSETS, &newState) 44 | if err != nil { 45 | return nil, err 46 | } 47 | 48 | defer unix.IoctlSetTermios(fd, unix.TCSETS, &oldState) 49 | 50 | var buf [16]byte 51 | var ret []byte 52 | for { 53 | n, err := syscall.Read(fd, buf[:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | if n == 0 { 58 | if len(ret) == 0 { 59 | return nil, io.EOF 60 | } 61 | break 62 | } 63 | if buf[n-1] == '\n' { 64 | n-- 65 | } 66 | ret = append(ret, buf[:n]...) 67 | if n < len(buf) { 68 | break 69 | } 70 | } 71 | 72 | return ret, nil 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/swarm/container.go: -------------------------------------------------------------------------------- 1 | package swarm 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/docker/docker/api/types/container" 7 | "github.com/docker/docker/api/types/mount" 8 | ) 9 | 10 | // DNSConfig specifies DNS related configurations in resolver configuration file (resolv.conf) 11 | // Detailed documentation is available in: 12 | // http://man7.org/linux/man-pages/man5/resolv.conf.5.html 13 | // `nameserver`, `search`, `options` have been supported. 14 | // TODO: `domain` is not supported yet. 15 | type DNSConfig struct { 16 | // Nameservers specifies the IP addresses of the name servers 17 | Nameservers []string `json:",omitempty"` 18 | // Search specifies the search list for host-name lookup 19 | Search []string `json:",omitempty"` 20 | // Options allows certain internal resolver variables to be modified 21 | Options []string `json:",omitempty"` 22 | } 23 | 24 | // ContainerSpec represents the spec of a container. 25 | type ContainerSpec struct { 26 | Image string `json:",omitempty"` 27 | Labels map[string]string `json:",omitempty"` 28 | Command []string `json:",omitempty"` 29 | Args []string `json:",omitempty"` 30 | Hostname string `json:",omitempty"` 31 | Env []string `json:",omitempty"` 32 | Dir string `json:",omitempty"` 33 | User string `json:",omitempty"` 34 | Groups []string `json:",omitempty"` 35 | TTY bool `json:",omitempty"` 36 | OpenStdin bool `json:",omitempty"` 37 | Mounts []mount.Mount `json:",omitempty"` 38 | StopGracePeriod *time.Duration `json:",omitempty"` 39 | Healthcheck *container.HealthConfig `json:",omitempty"` 40 | // The format of extra hosts on swarmkit is specified in: 41 | // http://man7.org/linux/man-pages/man5/hosts.5.html 42 | // IP_address canonical_hostname [aliases...] 43 | Hosts []string `json:",omitempty"` 44 | DNSConfig *DNSConfig `json:",omitempty"` 45 | Secrets []*SecretReference `json:",omitempty"` 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/container_exec.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/docker/api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerExecCreate creates a new exec configuration to run an exec process. 11 | func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) { 12 | var response types.IDResponse 13 | 14 | if err := cli.NewVersionError("1.25", "env"); len(config.Env) != 0 && err != nil { 15 | return response, err 16 | } 17 | 18 | resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil) 19 | if err != nil { 20 | return response, err 21 | } 22 | err = json.NewDecoder(resp.body).Decode(&response) 23 | ensureReaderClosed(resp) 24 | return response, err 25 | } 26 | 27 | // ContainerExecStart starts an exec process already created in the docker host. 28 | func (cli *Client) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error { 29 | resp, err := cli.post(ctx, "/exec/"+execID+"/start", nil, config, nil) 30 | ensureReaderClosed(resp) 31 | return err 32 | } 33 | 34 | // ContainerExecAttach attaches a connection to an exec process in the server. 35 | // It returns a types.HijackedConnection with the hijacked connection 36 | // and the a reader to get output. It's up to the called to close 37 | // the hijacked connection by calling types.HijackedResponse.Close. 38 | func (cli *Client) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) { 39 | headers := map[string][]string{"Content-Type": {"application/json"}} 40 | return cli.postHijacked(ctx, "/exec/"+execID+"/start", nil, config, headers) 41 | } 42 | 43 | // ContainerExecInspect returns information about a specific exec process on the docker host. 44 | func (cli *Client) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) { 45 | var response types.ContainerExecInspect 46 | resp, err := cli.get(ctx, "/exec/"+execID+"/json", nil, nil) 47 | if err != nil { 48 | return response, err 49 | } 50 | 51 | err = json.NewDecoder(resp.body).Decode(&response) 52 | ensureReaderClosed(resp) 53 | return response, err 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package terminal provides support functions for dealing with terminals, as 6 | // commonly found on UNIX systems. 7 | // 8 | // Putting a terminal into raw mode is the most common requirement: 9 | // 10 | // oldState, err := terminal.MakeRaw(0) 11 | // if err != nil { 12 | // panic(err) 13 | // } 14 | // defer terminal.Restore(0, oldState) 15 | package terminal 16 | 17 | import ( 18 | "fmt" 19 | "runtime" 20 | ) 21 | 22 | type State struct{} 23 | 24 | // IsTerminal returns true if the given file descriptor is a terminal. 25 | func IsTerminal(fd int) bool { 26 | return false 27 | } 28 | 29 | // MakeRaw put the terminal connected to the given file descriptor into raw 30 | // mode and returns the previous state of the terminal so that it can be 31 | // restored. 32 | func MakeRaw(fd int) (*State, error) { 33 | return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 34 | } 35 | 36 | // GetState returns the current state of a terminal which may be useful to 37 | // restore the terminal after a signal. 38 | func GetState(fd int) (*State, error) { 39 | return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 40 | } 41 | 42 | // Restore restores the terminal connected to the given file descriptor to a 43 | // previous state. 44 | func Restore(fd int, state *State) error { 45 | return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 46 | } 47 | 48 | // GetSize returns the dimensions of the given terminal. 49 | func GetSize(fd int) (width, height int, err error) { 50 | return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 51 | } 52 | 53 | // ReadPassword reads a line of input from a terminal without local echo. This 54 | // is commonly used for inputting passwords and other sensitive data. The slice 55 | // returned does not include the \n. 56 | func ReadPassword(fd int) ([]byte, error) { 57 | return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/inmem_socket.go: -------------------------------------------------------------------------------- 1 | package sockets 2 | 3 | import ( 4 | "errors" 5 | "net" 6 | "sync" 7 | ) 8 | 9 | var errClosed = errors.New("use of closed network connection") 10 | 11 | // InmemSocket implements net.Listener using in-memory only connections. 12 | type InmemSocket struct { 13 | chConn chan net.Conn 14 | chClose chan struct{} 15 | addr string 16 | mu sync.Mutex 17 | } 18 | 19 | // dummyAddr is used to satisfy net.Addr for the in-mem socket 20 | // it is just stored as a string and returns the string for all calls 21 | type dummyAddr string 22 | 23 | // NewInmemSocket creates an in-memory only net.Listener 24 | // The addr argument can be any string, but is used to satisfy the `Addr()` part 25 | // of the net.Listener interface 26 | func NewInmemSocket(addr string, bufSize int) *InmemSocket { 27 | return &InmemSocket{ 28 | chConn: make(chan net.Conn, bufSize), 29 | chClose: make(chan struct{}), 30 | addr: addr, 31 | } 32 | } 33 | 34 | // Addr returns the socket's addr string to satisfy net.Listener 35 | func (s *InmemSocket) Addr() net.Addr { 36 | return dummyAddr(s.addr) 37 | } 38 | 39 | // Accept implements the Accept method in the Listener interface; it waits for the next call and returns a generic Conn. 40 | func (s *InmemSocket) Accept() (net.Conn, error) { 41 | select { 42 | case conn := <-s.chConn: 43 | return conn, nil 44 | case <-s.chClose: 45 | return nil, errClosed 46 | } 47 | } 48 | 49 | // Close closes the listener. It will be unavailable for use once closed. 50 | func (s *InmemSocket) Close() error { 51 | s.mu.Lock() 52 | defer s.mu.Unlock() 53 | select { 54 | case <-s.chClose: 55 | default: 56 | close(s.chClose) 57 | } 58 | return nil 59 | } 60 | 61 | // Dial is used to establish a connection with the in-mem server 62 | func (s *InmemSocket) Dial(network, addr string) (net.Conn, error) { 63 | srvConn, clientConn := net.Pipe() 64 | select { 65 | case s.chConn <- srvConn: 66 | case <-s.chClose: 67 | return nil, errClosed 68 | } 69 | 70 | return clientConn, nil 71 | } 72 | 73 | // Network returns the addr string, satisfies net.Addr 74 | func (a dummyAddr) Network() string { 75 | return string(a) 76 | } 77 | 78 | // String returns the string form 79 | func (a dummyAddr) String() string { 80 | return string(a) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package container 4 | 5 | import "strings" 6 | 7 | // IsValid indicates if an isolation technology is valid 8 | func (i Isolation) IsValid() bool { 9 | return i.IsDefault() 10 | } 11 | 12 | // IsPrivate indicates whether container uses its private network stack. 13 | func (n NetworkMode) IsPrivate() bool { 14 | return !(n.IsHost() || n.IsContainer()) 15 | } 16 | 17 | // IsDefault indicates whether container uses the default network stack. 18 | func (n NetworkMode) IsDefault() bool { 19 | return n == "default" 20 | } 21 | 22 | // NetworkName returns the name of the network stack. 23 | func (n NetworkMode) NetworkName() string { 24 | if n.IsBridge() { 25 | return "bridge" 26 | } else if n.IsHost() { 27 | return "host" 28 | } else if n.IsContainer() { 29 | return "container" 30 | } else if n.IsNone() { 31 | return "none" 32 | } else if n.IsDefault() { 33 | return "default" 34 | } else if n.IsUserDefined() { 35 | return n.UserDefined() 36 | } 37 | return "" 38 | } 39 | 40 | // IsBridge indicates whether container uses the bridge network stack 41 | func (n NetworkMode) IsBridge() bool { 42 | return n == "bridge" 43 | } 44 | 45 | // IsHost indicates whether container uses the host network stack. 46 | func (n NetworkMode) IsHost() bool { 47 | return n == "host" 48 | } 49 | 50 | // IsContainer indicates whether container uses a container network stack. 51 | func (n NetworkMode) IsContainer() bool { 52 | parts := strings.SplitN(string(n), ":", 2) 53 | return len(parts) > 1 && parts[0] == "container" 54 | } 55 | 56 | // IsNone indicates whether container isn't using a network stack. 57 | func (n NetworkMode) IsNone() bool { 58 | return n == "none" 59 | } 60 | 61 | // ConnectedContainer is the id of the container which network this container is connected to. 62 | func (n NetworkMode) ConnectedContainer() string { 63 | parts := strings.SplitN(string(n), ":", 2) 64 | if len(parts) > 1 { 65 | return parts[1] 66 | } 67 | return "" 68 | } 69 | 70 | // IsUserDefined indicates user-created network 71 | func (n NetworkMode) IsUserDefined() bool { 72 | return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() 73 | } 74 | 75 | //UserDefined indicates user-created network 76 | func (n NetworkMode) UserDefined() string { 77 | if n.IsUserDefined() { 78 | return string(n) 79 | } 80 | return "" 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/configs.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/docker/docker/api/types/container" 5 | "github.com/docker/docker/api/types/network" 6 | ) 7 | 8 | // configs holds structs used for internal communication between the 9 | // frontend (such as an http server) and the backend (such as the 10 | // docker daemon). 11 | 12 | // ContainerCreateConfig is the parameter set to ContainerCreate() 13 | type ContainerCreateConfig struct { 14 | Name string 15 | Config *container.Config 16 | HostConfig *container.HostConfig 17 | NetworkingConfig *network.NetworkingConfig 18 | AdjustCPUShares bool 19 | } 20 | 21 | // ContainerRmConfig holds arguments for the container remove 22 | // operation. This struct is used to tell the backend what operations 23 | // to perform. 24 | type ContainerRmConfig struct { 25 | ForceRemove, RemoveVolume, RemoveLink bool 26 | } 27 | 28 | // ContainerCommitConfig contains build configs for commit operation, 29 | // and is used when making a commit with the current state of the container. 30 | type ContainerCommitConfig struct { 31 | Pause bool 32 | Repo string 33 | Tag string 34 | Author string 35 | Comment string 36 | // merge container config into commit config before commit 37 | MergeConfigs bool 38 | Config *container.Config 39 | } 40 | 41 | // ExecConfig is a small subset of the Config struct that holds the configuration 42 | // for the exec feature of docker. 43 | type ExecConfig struct { 44 | User string // User that will run the command 45 | Privileged bool // Is the container in privileged mode 46 | Tty bool // Attach standard streams to a tty. 47 | AttachStdin bool // Attach the standard input, makes possible user interaction 48 | AttachStderr bool // Attach the standard error 49 | AttachStdout bool // Attach the standard output 50 | Detach bool // Execute in detach mode 51 | DetachKeys string // Escape keys for detach 52 | Env []string // Environment variables 53 | Cmd []string // Execution commands and args 54 | } 55 | 56 | // PluginRmConfig holds arguments for plugin remove. 57 | type PluginRmConfig struct { 58 | ForceRemove bool 59 | } 60 | 61 | // PluginEnableConfig holds arguments for plugin enable 62 | type PluginEnableConfig struct { 63 | Timeout int 64 | } 65 | 66 | // PluginDisableConfig holds arguments for plugin disable. 67 | type PluginDisableConfig struct { 68 | ForceDisable bool 69 | } 70 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | // Package ctxhttp provides helper functions for performing context-aware HTTP requests. 8 | package ctxhttp // import "golang.org/x/net/context/ctxhttp" 9 | 10 | import ( 11 | "io" 12 | "net/http" 13 | "net/url" 14 | "strings" 15 | 16 | "golang.org/x/net/context" 17 | ) 18 | 19 | // Do sends an HTTP request with the provided http.Client and returns 20 | // an HTTP response. 21 | // 22 | // If the client is nil, http.DefaultClient is used. 23 | // 24 | // The provided ctx must be non-nil. If it is canceled or times out, 25 | // ctx.Err() will be returned. 26 | func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { 27 | if client == nil { 28 | client = http.DefaultClient 29 | } 30 | resp, err := client.Do(req.WithContext(ctx)) 31 | // If we got an error, and the context has been canceled, 32 | // the context's error is probably more useful. 33 | if err != nil { 34 | select { 35 | case <-ctx.Done(): 36 | err = ctx.Err() 37 | default: 38 | } 39 | } 40 | return resp, err 41 | } 42 | 43 | // Get issues a GET request via the Do function. 44 | func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { 45 | req, err := http.NewRequest("GET", url, nil) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return Do(ctx, client, req) 50 | } 51 | 52 | // Head issues a HEAD request via the Do function. 53 | func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { 54 | req, err := http.NewRequest("HEAD", url, nil) 55 | if err != nil { 56 | return nil, err 57 | } 58 | return Do(ctx, client, req) 59 | } 60 | 61 | // Post issues a POST request via the Do function. 62 | func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { 63 | req, err := http.NewRequest("POST", url, body) 64 | if err != nil { 65 | return nil, err 66 | } 67 | req.Header.Set("Content-Type", bodyType) 68 | return Do(ctx, client, req) 69 | } 70 | 71 | // PostForm issues a POST request via the Do function. 72 | func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { 73 | return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/alt_exit.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // The following code was sourced and modified from the 4 | // https://bitbucket.org/tebeka/atexit package governed by the following license: 5 | // 6 | // Copyright (c) 2012 Miki Tebeka . 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | // this software and associated documentation files (the "Software"), to deal in 10 | // the Software without restriction, including without limitation the rights to 11 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12 | // the Software, and to permit persons to whom the Software is furnished to do so, 13 | // subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | import ( 26 | "fmt" 27 | "os" 28 | ) 29 | 30 | var handlers = []func(){} 31 | 32 | func runHandler(handler func()) { 33 | defer func() { 34 | if err := recover(); err != nil { 35 | fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) 36 | } 37 | }() 38 | 39 | handler() 40 | } 41 | 42 | func runHandlers() { 43 | for _, handler := range handlers { 44 | runHandler(handler) 45 | } 46 | } 47 | 48 | // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) 49 | func Exit(code int) { 50 | runHandlers() 51 | os.Exit(code) 52 | } 53 | 54 | // RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke 55 | // all handlers. The handlers will also be invoked when any Fatal log entry is 56 | // made. 57 | // 58 | // This method is useful when a caller wishes to use logrus to log a fatal 59 | // message but also needs to gracefully shutdown. An example usecase could be 60 | // closing database connections, or sending a alert that the application is 61 | // closing. 62 | func RegisterExitHandler(handler func()) { 63 | handlers = append(handlers, handler) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/nat/sort.go: -------------------------------------------------------------------------------- 1 | package nat 2 | 3 | import ( 4 | "sort" 5 | "strings" 6 | ) 7 | 8 | type portSorter struct { 9 | ports []Port 10 | by func(i, j Port) bool 11 | } 12 | 13 | func (s *portSorter) Len() int { 14 | return len(s.ports) 15 | } 16 | 17 | func (s *portSorter) Swap(i, j int) { 18 | s.ports[i], s.ports[j] = s.ports[j], s.ports[i] 19 | } 20 | 21 | func (s *portSorter) Less(i, j int) bool { 22 | ip := s.ports[i] 23 | jp := s.ports[j] 24 | 25 | return s.by(ip, jp) 26 | } 27 | 28 | // Sort sorts a list of ports using the provided predicate 29 | // This function should compare `i` and `j`, returning true if `i` is 30 | // considered to be less than `j` 31 | func Sort(ports []Port, predicate func(i, j Port) bool) { 32 | s := &portSorter{ports, predicate} 33 | sort.Sort(s) 34 | } 35 | 36 | type portMapEntry struct { 37 | port Port 38 | binding PortBinding 39 | } 40 | 41 | type portMapSorter []portMapEntry 42 | 43 | func (s portMapSorter) Len() int { return len(s) } 44 | func (s portMapSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 45 | 46 | // sort the port so that the order is: 47 | // 1. port with larger specified bindings 48 | // 2. larger port 49 | // 3. port with tcp protocol 50 | func (s portMapSorter) Less(i, j int) bool { 51 | pi, pj := s[i].port, s[j].port 52 | hpi, hpj := toInt(s[i].binding.HostPort), toInt(s[j].binding.HostPort) 53 | return hpi > hpj || pi.Int() > pj.Int() || (pi.Int() == pj.Int() && strings.ToLower(pi.Proto()) == "tcp") 54 | } 55 | 56 | // SortPortMap sorts the list of ports and their respected mapping. The ports 57 | // will explicit HostPort will be placed first. 58 | func SortPortMap(ports []Port, bindings PortMap) { 59 | s := portMapSorter{} 60 | for _, p := range ports { 61 | if binding, ok := bindings[p]; ok { 62 | for _, b := range binding { 63 | s = append(s, portMapEntry{port: p, binding: b}) 64 | } 65 | bindings[p] = []PortBinding{} 66 | } else { 67 | s = append(s, portMapEntry{port: p}) 68 | } 69 | } 70 | 71 | sort.Sort(s) 72 | var ( 73 | i int 74 | pm = make(map[Port]struct{}) 75 | ) 76 | // reorder ports 77 | for _, entry := range s { 78 | if _, ok := pm[entry.port]; !ok { 79 | ports[i] = entry.port 80 | pm[entry.port] = struct{}{} 81 | i++ 82 | } 83 | // reorder bindings for this port 84 | if _, ok := bindings[entry.port]; ok { 85 | bindings[entry.port] = append(bindings[entry.port], entry.binding) 86 | } 87 | } 88 | } 89 | 90 | func toInt(s string) uint64 { 91 | i, _, err := ParsePortRange(s) 92 | if err != nil { 93 | i = 0 94 | } 95 | return i 96 | } 97 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go: -------------------------------------------------------------------------------- 1 | package container 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | // IsDefault indicates whether container uses the default network stack. 8 | func (n NetworkMode) IsDefault() bool { 9 | return n == "default" 10 | } 11 | 12 | // IsNone indicates whether container isn't using a network stack. 13 | func (n NetworkMode) IsNone() bool { 14 | return n == "none" 15 | } 16 | 17 | // IsContainer indicates whether container uses a container network stack. 18 | // Returns false as windows doesn't support this mode 19 | func (n NetworkMode) IsContainer() bool { 20 | return false 21 | } 22 | 23 | // IsBridge indicates whether container uses the bridge network stack 24 | // in windows it is given the name NAT 25 | func (n NetworkMode) IsBridge() bool { 26 | return n == "nat" 27 | } 28 | 29 | // IsHost indicates whether container uses the host network stack. 30 | // returns false as this is not supported by windows 31 | func (n NetworkMode) IsHost() bool { 32 | return false 33 | } 34 | 35 | // IsPrivate indicates whether container uses its private network stack. 36 | func (n NetworkMode) IsPrivate() bool { 37 | return !(n.IsHost() || n.IsContainer()) 38 | } 39 | 40 | // ConnectedContainer is the id of the container which network this container is connected to. 41 | // Returns blank string on windows 42 | func (n NetworkMode) ConnectedContainer() string { 43 | return "" 44 | } 45 | 46 | // IsUserDefined indicates user-created network 47 | func (n NetworkMode) IsUserDefined() bool { 48 | return !n.IsDefault() && !n.IsNone() && !n.IsBridge() 49 | } 50 | 51 | // IsHyperV indicates the use of a Hyper-V partition for isolation 52 | func (i Isolation) IsHyperV() bool { 53 | return strings.ToLower(string(i)) == "hyperv" 54 | } 55 | 56 | // IsProcess indicates the use of process isolation 57 | func (i Isolation) IsProcess() bool { 58 | return strings.ToLower(string(i)) == "process" 59 | } 60 | 61 | // IsValid indicates if an isolation technology is valid 62 | func (i Isolation) IsValid() bool { 63 | return i.IsDefault() || i.IsHyperV() || i.IsProcess() 64 | } 65 | 66 | // NetworkName returns the name of the network stack. 67 | func (n NetworkMode) NetworkName() string { 68 | if n.IsDefault() { 69 | return "default" 70 | } else if n.IsBridge() { 71 | return "nat" 72 | } else if n.IsNone() { 73 | return "none" 74 | } else if n.IsUserDefined() { 75 | return n.UserDefined() 76 | } 77 | 78 | return "" 79 | } 80 | 81 | //UserDefined indicates user-created network 82 | func (n NetworkMode) UserDefined() string { 83 | if n.IsUserDefined() { 84 | return string(n) 85 | } 86 | return "" 87 | } 88 | -------------------------------------------------------------------------------- /cmd/buildcache/save.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "io/ioutil" 7 | "os" 8 | "os/signal" 9 | "path/filepath" 10 | "syscall" 11 | 12 | "github.com/Sirupsen/logrus" 13 | engineapi "github.com/docker/docker/client" 14 | humanize "github.com/dustin/go-humanize" 15 | "github.com/spf13/cobra" 16 | "github.com/tonistiigi/buildcache" 17 | "golang.org/x/crypto/ssh/terminal" 18 | "golang.org/x/net/context" 19 | ) 20 | 21 | var saveCmd = &cobra.Command{ 22 | Use: "save [image]", 23 | Short: "Save buildcache", 24 | RunE: runSave, 25 | } 26 | 27 | func init() { 28 | saveCmd.Flags().StringP("output", "o", "-", "output file") 29 | saveCmd.Flags().StringP("graph", "g", "", "graph directory") 30 | } 31 | 32 | func callOnSignal(ctx context.Context, fn func(), s ...os.Signal) { 33 | ctx, c := context.WithCancel(ctx) 34 | sigchan := make(chan os.Signal, 1) 35 | signal.Notify(sigchan, s...) 36 | go func() { 37 | for range sigchan { 38 | logrus.Debugf("received signal") 39 | fn() 40 | c() 41 | } 42 | }() 43 | go func() { 44 | <-ctx.Done() 45 | signal.Stop(sigchan) 46 | }() 47 | } 48 | 49 | func runSave(cmd *cobra.Command, args []string) (reterr error) { 50 | if len(args) == 0 { 51 | return errors.New("image reference missing") 52 | } 53 | 54 | output, err := cmd.Flags().GetString("output") 55 | if err != nil { 56 | return err 57 | } 58 | 59 | if output == "-" && terminal.IsTerminal(int(os.Stdout.Fd())) { 60 | return errors.New("refusing to output to terminal, specify output file") 61 | } 62 | 63 | client, err := engineapi.NewEnvClient() 64 | if err != nil { 65 | return err 66 | } 67 | 68 | ctx, cancel := context.WithCancel(context.Background()) 69 | callOnSignal(ctx, cancel, syscall.SIGINT) 70 | defer cancel() 71 | 72 | graphdir, err := cmd.Flags().GetString("graph") 73 | if err != nil { 74 | return err 75 | } 76 | 77 | c, err := buildcache.New(client).Get(ctx, graphdir, args[0]) 78 | if err != nil { 79 | return err 80 | } 81 | 82 | if output == "-" { 83 | _, err := io.Copy(os.Stdout, c) 84 | return err 85 | } 86 | 87 | f, err := ioutil.TempFile(filepath.Dir(output), ".buildcache-") 88 | if err != nil { 89 | return err 90 | } 91 | defer func() { 92 | if reterr != nil { 93 | os.RemoveAll(f.Name()) 94 | } 95 | }() 96 | if n, err := io.Copy(f, c); err != nil { 97 | return err 98 | } else { 99 | logrus.Debugf("saving: %v", humanize.Bytes(uint64(n))) 100 | } 101 | if err := f.Sync(); err != nil { 102 | return err 103 | } 104 | if err := f.Close(); err != nil { 105 | return err 106 | } 107 | return os.Rename(f.Name(), output) 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/comma.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "bytes" 5 | "math" 6 | "math/big" 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | // Comma produces a string form of the given number in base 10 with 12 | // commas after every three orders of magnitude. 13 | // 14 | // e.g. Comma(834142) -> 834,142 15 | func Comma(v int64) string { 16 | sign := "" 17 | 18 | // minin64 can't be negated to a usable value, so it has to be special cased. 19 | if v == math.MinInt64 { 20 | return "-9,223,372,036,854,775,808" 21 | } 22 | 23 | if v < 0 { 24 | sign = "-" 25 | v = 0 - v 26 | } 27 | 28 | parts := []string{"", "", "", "", "", "", ""} 29 | j := len(parts) - 1 30 | 31 | for v > 999 { 32 | parts[j] = strconv.FormatInt(v%1000, 10) 33 | switch len(parts[j]) { 34 | case 2: 35 | parts[j] = "0" + parts[j] 36 | case 1: 37 | parts[j] = "00" + parts[j] 38 | } 39 | v = v / 1000 40 | j-- 41 | } 42 | parts[j] = strconv.Itoa(int(v)) 43 | return sign + strings.Join(parts[j:], ",") 44 | } 45 | 46 | // Commaf produces a string form of the given number in base 10 with 47 | // commas after every three orders of magnitude. 48 | // 49 | // e.g. Commaf(834142.32) -> 834,142.32 50 | func Commaf(v float64) string { 51 | buf := &bytes.Buffer{} 52 | if v < 0 { 53 | buf.Write([]byte{'-'}) 54 | v = 0 - v 55 | } 56 | 57 | comma := []byte{','} 58 | 59 | parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".") 60 | pos := 0 61 | if len(parts[0])%3 != 0 { 62 | pos += len(parts[0]) % 3 63 | buf.WriteString(parts[0][:pos]) 64 | buf.Write(comma) 65 | } 66 | for ; pos < len(parts[0]); pos += 3 { 67 | buf.WriteString(parts[0][pos : pos+3]) 68 | buf.Write(comma) 69 | } 70 | buf.Truncate(buf.Len() - 1) 71 | 72 | if len(parts) > 1 { 73 | buf.Write([]byte{'.'}) 74 | buf.WriteString(parts[1]) 75 | } 76 | return buf.String() 77 | } 78 | 79 | // BigComma produces a string form of the given big.Int in base 10 80 | // with commas after every three orders of magnitude. 81 | func BigComma(b *big.Int) string { 82 | sign := "" 83 | if b.Sign() < 0 { 84 | sign = "-" 85 | b.Abs(b) 86 | } 87 | 88 | athousand := big.NewInt(1000) 89 | c := (&big.Int{}).Set(b) 90 | _, m := oom(c, athousand) 91 | parts := make([]string, m+1) 92 | j := len(parts) - 1 93 | 94 | mod := &big.Int{} 95 | for b.Cmp(athousand) >= 0 { 96 | b.DivMod(b, athousand, mod) 97 | parts[j] = strconv.FormatInt(mod.Int64(), 10) 98 | switch len(parts[j]) { 99 | case 2: 100 | parts[j] = "0" + parts[j] 101 | case 1: 102 | parts[j] = "00" + parts[j] 103 | } 104 | j-- 105 | } 106 | parts[j] = strconv.Itoa(int(b.Int64())) 107 | return sign + strings.Join(parts[j:], ",") 108 | } 109 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/client/events.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "time" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/docker/api/types" 11 | "github.com/docker/docker/api/types/events" 12 | "github.com/docker/docker/api/types/filters" 13 | timetypes "github.com/docker/docker/api/types/time" 14 | ) 15 | 16 | // Events returns a stream of events in the daemon. It's up to the caller to close the stream 17 | // by cancelling the context. Once the stream has been completely read an io.EOF error will 18 | // be sent over the error channel. If an error is sent all processing will be stopped. It's up 19 | // to the caller to reopen the stream in the event of an error by reinvoking this method. 20 | func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { 21 | 22 | messages := make(chan events.Message) 23 | errs := make(chan error, 1) 24 | 25 | started := make(chan struct{}) 26 | go func() { 27 | defer close(errs) 28 | 29 | query, err := buildEventsQueryParams(cli.version, options) 30 | if err != nil { 31 | close(started) 32 | errs <- err 33 | return 34 | } 35 | 36 | resp, err := cli.get(ctx, "/events", query, nil) 37 | if err != nil { 38 | close(started) 39 | errs <- err 40 | return 41 | } 42 | defer resp.body.Close() 43 | 44 | decoder := json.NewDecoder(resp.body) 45 | 46 | close(started) 47 | for { 48 | select { 49 | case <-ctx.Done(): 50 | errs <- ctx.Err() 51 | return 52 | default: 53 | var event events.Message 54 | if err := decoder.Decode(&event); err != nil { 55 | errs <- err 56 | return 57 | } 58 | 59 | select { 60 | case messages <- event: 61 | case <-ctx.Done(): 62 | errs <- ctx.Err() 63 | return 64 | } 65 | } 66 | } 67 | }() 68 | <-started 69 | 70 | return messages, errs 71 | } 72 | 73 | func buildEventsQueryParams(cliVersion string, options types.EventsOptions) (url.Values, error) { 74 | query := url.Values{} 75 | ref := time.Now() 76 | 77 | if options.Since != "" { 78 | ts, err := timetypes.GetTimestamp(options.Since, ref) 79 | if err != nil { 80 | return nil, err 81 | } 82 | query.Set("since", ts) 83 | } 84 | 85 | if options.Until != "" { 86 | ts, err := timetypes.GetTimestamp(options.Until, ref) 87 | if err != nil { 88 | return nil, err 89 | } 90 | query.Set("until", ts) 91 | } 92 | 93 | if options.Filters.Len() > 0 { 94 | filterJSON, err := filters.ToParamWithVersion(cliVersion, options.Filters) 95 | if err != nil { 96 | return nil, err 97 | } 98 | query.Set("filters", filterJSON) 99 | } 100 | 101 | return query, nil 102 | } 103 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/proxy/proxy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package proxy provides support for a variety of protocols to proxy network 6 | // data. 7 | package proxy // import "golang.org/x/net/proxy" 8 | 9 | import ( 10 | "errors" 11 | "net" 12 | "net/url" 13 | "os" 14 | ) 15 | 16 | // A Dialer is a means to establish a connection. 17 | type Dialer interface { 18 | // Dial connects to the given address via the proxy. 19 | Dial(network, addr string) (c net.Conn, err error) 20 | } 21 | 22 | // Auth contains authentication parameters that specific Dialers may require. 23 | type Auth struct { 24 | User, Password string 25 | } 26 | 27 | // FromEnvironment returns the dialer specified by the proxy related variables in 28 | // the environment. 29 | func FromEnvironment() Dialer { 30 | allProxy := os.Getenv("all_proxy") 31 | if len(allProxy) == 0 { 32 | return Direct 33 | } 34 | 35 | proxyURL, err := url.Parse(allProxy) 36 | if err != nil { 37 | return Direct 38 | } 39 | proxy, err := FromURL(proxyURL, Direct) 40 | if err != nil { 41 | return Direct 42 | } 43 | 44 | noProxy := os.Getenv("no_proxy") 45 | if len(noProxy) == 0 { 46 | return proxy 47 | } 48 | 49 | perHost := NewPerHost(proxy, Direct) 50 | perHost.AddFromString(noProxy) 51 | return perHost 52 | } 53 | 54 | // proxySchemes is a map from URL schemes to a function that creates a Dialer 55 | // from a URL with such a scheme. 56 | var proxySchemes map[string]func(*url.URL, Dialer) (Dialer, error) 57 | 58 | // RegisterDialerType takes a URL scheme and a function to generate Dialers from 59 | // a URL with that scheme and a forwarding Dialer. Registered schemes are used 60 | // by FromURL. 61 | func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error)) { 62 | if proxySchemes == nil { 63 | proxySchemes = make(map[string]func(*url.URL, Dialer) (Dialer, error)) 64 | } 65 | proxySchemes[scheme] = f 66 | } 67 | 68 | // FromURL returns a Dialer given a URL specification and an underlying 69 | // Dialer for it to make network requests. 70 | func FromURL(u *url.URL, forward Dialer) (Dialer, error) { 71 | var auth *Auth 72 | if u.User != nil { 73 | auth = new(Auth) 74 | auth.User = u.User.Username() 75 | if p, ok := u.User.Password(); ok { 76 | auth.Password = p 77 | } 78 | } 79 | 80 | switch u.Scheme { 81 | case "socks5": 82 | return SOCKS5("tcp", u.Host, auth, forward) 83 | } 84 | 85 | // If the scheme doesn't match any of the built-in schemes, see if it 86 | // was registered by another package. 87 | if proxySchemes != nil { 88 | if f, ok := proxySchemes[u.Scheme]; ok { 89 | return f(u, forward) 90 | } 91 | } 92 | 93 | return nil, errors.New("proxy: unknown scheme: " + u.Scheme) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/si.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "errors" 5 | "math" 6 | "regexp" 7 | "strconv" 8 | ) 9 | 10 | var siPrefixTable = map[float64]string{ 11 | -24: "y", // yocto 12 | -21: "z", // zepto 13 | -18: "a", // atto 14 | -15: "f", // femto 15 | -12: "p", // pico 16 | -9: "n", // nano 17 | -6: "µ", // micro 18 | -3: "m", // milli 19 | 0: "", 20 | 3: "k", // kilo 21 | 6: "M", // mega 22 | 9: "G", // giga 23 | 12: "T", // tera 24 | 15: "P", // peta 25 | 18: "E", // exa 26 | 21: "Z", // zetta 27 | 24: "Y", // yotta 28 | } 29 | 30 | var revSIPrefixTable = revfmap(siPrefixTable) 31 | 32 | // revfmap reverses the map and precomputes the power multiplier 33 | func revfmap(in map[float64]string) map[string]float64 { 34 | rv := map[string]float64{} 35 | for k, v := range in { 36 | rv[v] = math.Pow(10, k) 37 | } 38 | return rv 39 | } 40 | 41 | var riParseRegex *regexp.Regexp 42 | 43 | func init() { 44 | ri := `^([\-0-9.]+)\s?([` 45 | for _, v := range siPrefixTable { 46 | ri += v 47 | } 48 | ri += `]?)(.*)` 49 | 50 | riParseRegex = regexp.MustCompile(ri) 51 | } 52 | 53 | // ComputeSI finds the most appropriate SI prefix for the given number 54 | // and returns the prefix along with the value adjusted to be within 55 | // that prefix. 56 | // 57 | // See also: SI, ParseSI. 58 | // 59 | // e.g. ComputeSI(2.2345e-12) -> (2.2345, "p") 60 | func ComputeSI(input float64) (float64, string) { 61 | if input == 0 { 62 | return 0, "" 63 | } 64 | mag := math.Abs(input) 65 | exponent := math.Floor(logn(mag, 10)) 66 | exponent = math.Floor(exponent/3) * 3 67 | 68 | value := mag / math.Pow(10, exponent) 69 | 70 | // Handle special case where value is exactly 1000.0 71 | // Should return 1M instead of 1000k 72 | if value == 1000.0 { 73 | exponent += 3 74 | value = mag / math.Pow(10, exponent) 75 | } 76 | 77 | value = math.Copysign(value, input) 78 | 79 | prefix := siPrefixTable[exponent] 80 | return value, prefix 81 | } 82 | 83 | // SI returns a string with default formatting. 84 | // 85 | // SI uses Ftoa to format float value, removing trailing zeros. 86 | // 87 | // See also: ComputeSI, ParseSI. 88 | // 89 | // e.g. SI(1000000, B) -> 1MB 90 | // e.g. SI(2.2345e-12, "F") -> 2.2345pF 91 | func SI(input float64, unit string) string { 92 | value, prefix := ComputeSI(input) 93 | return Ftoa(value) + " " + prefix + unit 94 | } 95 | 96 | var errInvalid = errors.New("invalid input") 97 | 98 | // ParseSI parses an SI string back into the number and unit. 99 | // 100 | // See also: SI, ComputeSI. 101 | // 102 | // e.g. ParseSI(2.2345pF) -> (2.2345e-12, "F", nil) 103 | func ParseSI(input string) (float64, string, error) { 104 | found := riParseRegex.FindStringSubmatch(input) 105 | if len(found) != 4 { 106 | return 0, "", errInvalid 107 | } 108 | mag := revSIPrefixTable[found[2]] 109 | unit := found[3] 110 | 111 | base, err := strconv.ParseFloat(found[1], 64) 112 | return base * mag, unit, err 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "strconv" 4 | 5 | // -- int Value 6 | type intValue int 7 | 8 | func newIntValue(val int, p *int) *intValue { 9 | *p = val 10 | return (*intValue)(p) 11 | } 12 | 13 | func (i *intValue) Set(s string) error { 14 | v, err := strconv.ParseInt(s, 0, 64) 15 | *i = intValue(v) 16 | return err 17 | } 18 | 19 | func (i *intValue) Type() string { 20 | return "int" 21 | } 22 | 23 | func (i *intValue) String() string { return strconv.Itoa(int(*i)) } 24 | 25 | func intConv(sval string) (interface{}, error) { 26 | return strconv.Atoi(sval) 27 | } 28 | 29 | // GetInt return the int value of a flag with the given name 30 | func (f *FlagSet) GetInt(name string) (int, error) { 31 | val, err := f.getFlagType(name, "int", intConv) 32 | if err != nil { 33 | return 0, err 34 | } 35 | return val.(int), nil 36 | } 37 | 38 | // IntVar defines an int flag with specified name, default value, and usage string. 39 | // The argument p points to an int variable in which to store the value of the flag. 40 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { 41 | f.VarP(newIntValue(value, p), name, "", usage) 42 | } 43 | 44 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 45 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { 46 | f.VarP(newIntValue(value, p), name, shorthand, usage) 47 | } 48 | 49 | // IntVar defines an int flag with specified name, default value, and usage string. 50 | // The argument p points to an int variable in which to store the value of the flag. 51 | func IntVar(p *int, name string, value int, usage string) { 52 | CommandLine.VarP(newIntValue(value, p), name, "", usage) 53 | } 54 | 55 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 56 | func IntVarP(p *int, name, shorthand string, value int, usage string) { 57 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) 58 | } 59 | 60 | // Int defines an int flag with specified name, default value, and usage string. 61 | // The return value is the address of an int variable that stores the value of the flag. 62 | func (f *FlagSet) Int(name string, value int, usage string) *int { 63 | p := new(int) 64 | f.IntVarP(p, name, "", value, usage) 65 | return p 66 | } 67 | 68 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 69 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { 70 | p := new(int) 71 | f.IntVarP(p, name, shorthand, value, usage) 72 | return p 73 | } 74 | 75 | // Int defines an int flag with specified name, default value, and usage string. 76 | // The return value is the address of an int variable that stores the value of the flag. 77 | func Int(name string, value int, usage string) *int { 78 | return CommandLine.IntP(name, "", value, usage) 79 | } 80 | 81 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 82 | func IntP(name, shorthand string, value int, usage string) *int { 83 | return CommandLine.IntP(name, shorthand, value, usage) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/context/go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.7 6 | 7 | package context 8 | 9 | import ( 10 | "context" // standard library's context, as of Go 1.7 11 | "time" 12 | ) 13 | 14 | var ( 15 | todo = context.TODO() 16 | background = context.Background() 17 | ) 18 | 19 | // Canceled is the error returned by Context.Err when the context is canceled. 20 | var Canceled = context.Canceled 21 | 22 | // DeadlineExceeded is the error returned by Context.Err when the context's 23 | // deadline passes. 24 | var DeadlineExceeded = context.DeadlineExceeded 25 | 26 | // WithCancel returns a copy of parent with a new Done channel. The returned 27 | // context's Done channel is closed when the returned cancel function is called 28 | // or when the parent context's Done channel is closed, whichever happens first. 29 | // 30 | // Canceling this context releases resources associated with it, so code should 31 | // call cancel as soon as the operations running in this Context complete. 32 | func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { 33 | ctx, f := context.WithCancel(parent) 34 | return ctx, CancelFunc(f) 35 | } 36 | 37 | // WithDeadline returns a copy of the parent context with the deadline adjusted 38 | // to be no later than d. If the parent's deadline is already earlier than d, 39 | // WithDeadline(parent, d) is semantically equivalent to parent. The returned 40 | // context's Done channel is closed when the deadline expires, when the returned 41 | // cancel function is called, or when the parent context's Done channel is 42 | // closed, whichever happens first. 43 | // 44 | // Canceling this context releases resources associated with it, so code should 45 | // call cancel as soon as the operations running in this Context complete. 46 | func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { 47 | ctx, f := context.WithDeadline(parent, deadline) 48 | return ctx, CancelFunc(f) 49 | } 50 | 51 | // WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). 52 | // 53 | // Canceling this context releases resources associated with it, so code should 54 | // call cancel as soon as the operations running in this Context complete: 55 | // 56 | // func slowOperationWithTimeout(ctx context.Context) (Result, error) { 57 | // ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) 58 | // defer cancel() // releases resources if slowOperation completes before timeout elapses 59 | // return slowOperation(ctx) 60 | // } 61 | func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { 62 | return WithDeadline(parent, time.Now().Add(timeout)) 63 | } 64 | 65 | // WithValue returns a copy of parent in which the value associated with key is 66 | // val. 67 | // 68 | // Use context Values only for request-scoped data that transits processes and 69 | // APIs, not for passing optional parameters to functions. 70 | func WithValue(parent Context, key interface{}, val interface{}) Context { 71 | return context.WithValue(parent, key, val) 72 | } 73 | --------------------------------------------------------------------------------