diff --git a/imagebuildah/build.go b/imagebuildah/build.go index 4f0ffac1c0..eb29751730 100644 --- a/imagebuildah/build.go +++ b/imagebuildah/build.go @@ -27,11 +27,11 @@ import ( "github.com/containers/storage" "github.com/containers/storage/pkg/archive" "github.com/containers/storage/pkg/stringid" - "github.com/docker/docker/builder/dockerfile/parser" docker "github.com/fsouza/go-dockerclient" "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" "github.com/openshift/imagebuilder" + "github.com/openshift/imagebuilder/dockerfile/parser" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) diff --git a/vendor.conf b/vendor.conf index 3cdb9c95ff..53c2e673eb 100644 --- a/vendor.conf +++ b/vendor.conf @@ -11,12 +11,13 @@ github.com/boltdb/bolt v1.3.1 github.com/containers/libpod v1.0 github.com/containers/storage v1.11 github.com/docker/distribution 5f6282db7d65e6d72ad7c2cc66310724a57be716 -github.com/docker/docker 86f080cff0914e9694068ed78d503701667c4c00 +github.com/docker/docker 54dddadc7d5d89fe0be88f76979f6f6ab0dede83 github.com/docker/docker-credential-helpers v0.6.1 github.com/docker/go-connections v0.4.0 github.com/docker/go-units v0.3.2 github.com/docker/libtrust aabc10ec26b754e797f9028f4589c5b7bd90dc20 -github.com/fsouza/go-dockerclient 29c1814d12c072344bb91aac5d2ff719db39c523 +github.com/docker/libnetwork 1a06131fb8a047d919f7deaf02a4c414d7884b83 +github.com/fsouza/go-dockerclient v1.3.0 github.com/ghodss/yaml v1.0.0 github.com/gogo/protobuf v1.2.0 github.com/gorilla/context v1.1.1 @@ -38,7 +39,7 @@ github.com/opencontainers/runc v1.0.0-rc6 github.com/opencontainers/runtime-spec v1.0.0 github.com/opencontainers/runtime-tools v0.8.0 github.com/opencontainers/selinux v1.1 -github.com/openshift/imagebuilder 36823496a6868f72bc36282cc475eb8a070c0934 +github.com/openshift/imagebuilder 705fe9255c57f8505efb9723a9ac4082b67973bc github.com/ostreedev/ostree-go 9ab99253d365aac3a330d1f7281cf29f3d22820b github.com/pkg/errors v0.8.1 github.com/pquerna/ffjson d49c2bc1aa135aad0c6f4fc2056623ec78f5d5ac diff --git a/vendor/github.com/docker/docker/LICENSE b/vendor/github.com/docker/docker/LICENSE index 9c8e20ab85..6d8d58fb67 100644 --- a/vendor/github.com/docker/docker/LICENSE +++ b/vendor/github.com/docker/docker/LICENSE @@ -176,7 +176,7 @@ END OF TERMS AND CONDITIONS - Copyright 2013-2017 Docker, Inc. + Copyright 2013-2018 Docker, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/docker/docker/api/common.go b/vendor/github.com/docker/docker/api/common.go index d0229e0389..aa146cdaeb 100644 --- a/vendor/github.com/docker/docker/api/common.go +++ b/vendor/github.com/docker/docker/api/common.go @@ -1,11 +1,11 @@ -package api +package api // import "github.com/docker/docker/api" // Common constants for daemon and client. const ( // DefaultVersion of Current REST API - DefaultVersion string = "1.34" + DefaultVersion = "1.40" // NoBaseImageSpecifier is the symbol used by the FROM // command to specify that no base image is to be used. - NoBaseImageSpecifier string = "scratch" + NoBaseImageSpecifier = "scratch" ) diff --git a/vendor/github.com/docker/docker/api/common_unix.go b/vendor/github.com/docker/docker/api/common_unix.go index 081e61c451..504b0c90d7 100644 --- a/vendor/github.com/docker/docker/api/common_unix.go +++ b/vendor/github.com/docker/docker/api/common_unix.go @@ -1,6 +1,6 @@ // +build !windows -package api +package api // import "github.com/docker/docker/api" // MinVersion represents Minimum REST API version supported -const MinVersion string = "1.12" +const MinVersion = "1.12" diff --git a/vendor/github.com/docker/docker/api/common_windows.go b/vendor/github.com/docker/docker/api/common_windows.go index a6268a4ff7..590ba5479b 100644 --- a/vendor/github.com/docker/docker/api/common_windows.go +++ b/vendor/github.com/docker/docker/api/common_windows.go @@ -1,4 +1,4 @@ -package api +package api // import "github.com/docker/docker/api" // MinVersion represents Minimum REST API version supported // Technically the first daemon API version released on Windows is v1.25 in diff --git a/vendor/github.com/docker/docker/api/types/auth.go b/vendor/github.com/docker/docker/api/types/auth.go index 056af6b842..ddf15bb182 100644 --- a/vendor/github.com/docker/docker/api/types/auth.go +++ b/vendor/github.com/docker/docker/api/types/auth.go @@ -1,4 +1,4 @@ -package types +package types // import "github.com/docker/docker/api/types" // AuthConfig contains authorization information for connecting to a Registry type AuthConfig struct { diff --git a/vendor/github.com/docker/docker/api/types/blkiodev/blkio.go b/vendor/github.com/docker/docker/api/types/blkiodev/blkio.go index 931ae10ab1..bf3463b90e 100644 --- a/vendor/github.com/docker/docker/api/types/blkiodev/blkio.go +++ b/vendor/github.com/docker/docker/api/types/blkiodev/blkio.go @@ -1,4 +1,4 @@ -package blkiodev +package blkiodev // import "github.com/docker/docker/api/types/blkiodev" import "fmt" diff --git a/vendor/github.com/docker/docker/api/types/client.go b/vendor/github.com/docker/docker/api/types/client.go index db37f1fe4e..3b698c2c24 100644 --- a/vendor/github.com/docker/docker/api/types/client.go +++ b/vendor/github.com/docker/docker/api/types/client.go @@ -1,4 +1,4 @@ -package types +package types // import "github.com/docker/docker/api/types" import ( "bufio" @@ -74,6 +74,7 @@ type ContainerLogsOptions struct { ShowStdout bool ShowStderr bool Since string + Until string Timestamps bool Follow bool Tail string @@ -180,8 +181,24 @@ type ImageBuildOptions struct { Target string SessionID string Platform string + // Version specifies the version of the unerlying builder to use + Version BuilderVersion + // BuildID is an optional identifier that can be passed together with the + // build request. The same identifier can be used to gracefully cancel the + // build with the cancel request. + BuildID string } +// BuilderVersion sets the version of underlying builder to use +type BuilderVersion string + +const ( + // BuilderV1 is the first generation builder in docker daemon + BuilderV1 BuilderVersion = "1" + // BuilderBuildKit is builder based on moby/buildkit project + BuilderBuildKit = "2" +) + // ImageBuildResponse holds information // returned by a server after building // an image. diff --git a/vendor/github.com/docker/docker/api/types/configs.go b/vendor/github.com/docker/docker/api/types/configs.go index 20c19f2132..178e911a7a 100644 --- a/vendor/github.com/docker/docker/api/types/configs.go +++ b/vendor/github.com/docker/docker/api/types/configs.go @@ -1,4 +1,4 @@ -package types +package types // import "github.com/docker/docker/api/types" import ( "github.com/docker/docker/api/types/container" @@ -25,19 +25,6 @@ type ContainerRmConfig struct { ForceRemove, RemoveVolume, RemoveLink bool } -// ContainerCommitConfig contains build configs for commit operation, -// and is used when making a commit with the current state of the container. -type ContainerCommitConfig struct { - Pause bool - Repo string - Tag string - Author string - Comment string - // merge container config into commit config before commit - MergeConfigs bool - Config *container.Config -} - // ExecConfig is a small subset of the Config struct that holds the configuration // for the exec feature of docker. type ExecConfig struct { @@ -50,6 +37,7 @@ type ExecConfig struct { Detach bool // Execute in detach mode DetachKeys string // Escape keys for detach Env []string // Environment variables + WorkingDir string // Working directory Cmd []string // Execution commands and args } @@ -67,3 +55,10 @@ type PluginEnableConfig struct { type PluginDisableConfig struct { ForceDisable bool } + +// NetworkListConfig stores the options available for listing networks +type NetworkListConfig struct { + // TODO(@cpuguy83): naming is hard, this is pulled from what was being used in the router before moving here + Detailed bool + Verbose bool +} diff --git a/vendor/github.com/docker/docker/api/types/container/config.go b/vendor/github.com/docker/docker/api/types/container/config.go index 55a03fc981..89ad08c234 100644 --- a/vendor/github.com/docker/docker/api/types/container/config.go +++ b/vendor/github.com/docker/docker/api/types/container/config.go @@ -1,4 +1,4 @@ -package container +package container // import "github.com/docker/docker/api/types/container" import ( "time" diff --git a/vendor/github.com/docker/docker/api/types/container/container_changes.go b/vendor/github.com/docker/docker/api/types/container/container_changes.go index 767945a532..c909d6ca3e 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_changes.go +++ b/vendor/github.com/docker/docker/api/types/container/container_changes.go @@ -7,7 +7,7 @@ package container // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// ContainerChangeResponseItem container change response item +// ContainerChangeResponseItem change item in response to ContainerChanges operation // swagger:model ContainerChangeResponseItem type ContainerChangeResponseItem struct { diff --git a/vendor/github.com/docker/docker/api/types/container/container_create.go b/vendor/github.com/docker/docker/api/types/container/container_create.go index c95023b814..49efa0f2c0 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_create.go +++ b/vendor/github.com/docker/docker/api/types/container/container_create.go @@ -7,7 +7,7 @@ package container // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// ContainerCreateCreatedBody container create created body +// ContainerCreateCreatedBody OK response to ContainerCreate operation // swagger:model ContainerCreateCreatedBody type ContainerCreateCreatedBody struct { diff --git a/vendor/github.com/docker/docker/api/types/container/container_top.go b/vendor/github.com/docker/docker/api/types/container/container_top.go index 78bc37ee5e..ba41edcf3f 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_top.go +++ b/vendor/github.com/docker/docker/api/types/container/container_top.go @@ -7,7 +7,7 @@ package container // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// ContainerTopOKBody container top o k body +// ContainerTopOKBody OK response to ContainerTop operation // swagger:model ContainerTopOKBody type ContainerTopOKBody struct { diff --git a/vendor/github.com/docker/docker/api/types/container/container_update.go b/vendor/github.com/docker/docker/api/types/container/container_update.go index 2339366fbd..7630ae54cd 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_update.go +++ b/vendor/github.com/docker/docker/api/types/container/container_update.go @@ -7,7 +7,7 @@ package container // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// ContainerUpdateOKBody container update o k body +// ContainerUpdateOKBody OK response to ContainerUpdate operation // swagger:model ContainerUpdateOKBody type ContainerUpdateOKBody struct { diff --git a/vendor/github.com/docker/docker/api/types/container/container_wait.go b/vendor/github.com/docker/docker/api/types/container/container_wait.go index 77ecdbaf7a..9e3910a6b4 100644 --- a/vendor/github.com/docker/docker/api/types/container/container_wait.go +++ b/vendor/github.com/docker/docker/api/types/container/container_wait.go @@ -7,10 +7,22 @@ package container // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// ContainerWaitOKBody container wait o k body +// ContainerWaitOKBodyError container waiting error, if any +// swagger:model ContainerWaitOKBodyError +type ContainerWaitOKBodyError struct { + + // Details of an error + Message string `json:"Message,omitempty"` +} + +// ContainerWaitOKBody OK response to ContainerWait operation // swagger:model ContainerWaitOKBody type ContainerWaitOKBody struct { + // error + // Required: true + Error *ContainerWaitOKBodyError `json:"Error"` + // Exit code of the container // Required: true StatusCode int64 `json:"StatusCode"` diff --git a/vendor/github.com/docker/docker/api/types/container/host_config.go b/vendor/github.com/docker/docker/api/types/container/host_config.go index bb421b3889..f4f5c09f84 100644 --- a/vendor/github.com/docker/docker/api/types/container/host_config.go +++ b/vendor/github.com/docker/docker/api/types/container/host_config.go @@ -1,4 +1,4 @@ -package container +package container // import "github.com/docker/docker/api/types/container" import ( "strings" @@ -20,6 +20,27 @@ func (i Isolation) IsDefault() bool { return strings.ToLower(string(i)) == "default" || string(i) == "" } +// IsHyperV indicates the use of a Hyper-V partition for isolation +func (i Isolation) IsHyperV() bool { + return strings.ToLower(string(i)) == "hyperv" +} + +// IsProcess indicates the use of process isolation +func (i Isolation) IsProcess() bool { + return strings.ToLower(string(i)) == "process" +} + +const ( + // IsolationEmpty is unspecified (same behavior as default) + IsolationEmpty = Isolation("") + // IsolationDefault is the default isolation mode on current daemon + IsolationDefault = Isolation("default") + // IsolationProcess is process isolation mode + IsolationProcess = Isolation("process") + // IsolationHyperV is HyperV isolation mode + IsolationHyperV = Isolation("hyperv") +) + // IpcMode represents the container ipc stack. type IpcMode string @@ -308,11 +329,12 @@ type Resources struct { DeviceCgroupRules []string // List of rule to be added to the device cgroup DiskQuota int64 // Disk limit (in bytes) KernelMemory int64 // Kernel memory limit (in bytes) + KernelMemoryTCP int64 // Hard limit for kernel TCP buffer memory (in bytes) MemoryReservation int64 // Memory soft limit (in bytes) MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap MemorySwappiness *int64 // Tuning container memory swappiness behaviour OomKillDisable *bool // Whether to disable OOM Killer or not - PidsLimit int64 // Setting pids limit for a container + PidsLimit *int64 // Setting PIDs limit for a container; Set `0` or `-1` for unlimited, or `null` to not change. Ulimits []*units.Ulimit // List of ulimits to be set in the container // Applicable to Windows @@ -348,9 +370,10 @@ type HostConfig struct { // Applicable to UNIX platforms CapAdd strslice.StrSlice // List of kernel capabilities to add to the container CapDrop strslice.StrSlice // List of kernel capabilities to remove from the container - DNS []string `json:"Dns"` // List of DNS server to lookup - DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for - DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for + Capabilities []string `json:"Capabilities"` // List of kernel capabilities to be available for container (this overrides the default set) + DNS []string `json:"Dns"` // List of DNS server to lookup + DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for + DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for ExtraHosts []string // List of extra hosts GroupAdd []string // List of additional groups that the container process will run as IpcMode IpcMode // IPC namespace to use for the container @@ -380,6 +403,12 @@ type HostConfig struct { // Mounts specs used by the container Mounts []mount.Mount `json:",omitempty"` + // MaskedPaths is the list of paths to be masked inside the container (this overrides the default set of paths) + MaskedPaths []string + + // ReadonlyPaths is the list of paths to be set as read-only inside the container (this overrides the default set of paths) + ReadonlyPaths []string + // Run a custom init inside the container, if null, use the daemon's configured settings Init *bool `json:",omitempty"` } diff --git a/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go b/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go index 2d664d1c96..cf6fdf4402 100644 --- a/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go +++ b/vendor/github.com/docker/docker/api/types/container/hostconfig_unix.go @@ -1,6 +1,6 @@ // +build !windows -package container +package container // import "github.com/docker/docker/api/types/container" // IsValid indicates if an isolation technology is valid func (i Isolation) IsValid() bool { diff --git a/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go b/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go index 469923f7e9..99f803a5bb 100644 --- a/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go +++ b/vendor/github.com/docker/docker/api/types/container/hostconfig_windows.go @@ -1,8 +1,4 @@ -package container - -import ( - "strings" -) +package container // import "github.com/docker/docker/api/types/container" // IsBridge indicates whether container uses the bridge network stack // in windows it is given the name NAT @@ -21,16 +17,6 @@ func (n NetworkMode) IsUserDefined() bool { return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer() } -// IsHyperV indicates the use of a Hyper-V partition for isolation -func (i Isolation) IsHyperV() bool { - return strings.ToLower(string(i)) == "hyperv" -} - -// IsProcess indicates the use of process isolation -func (i Isolation) IsProcess() bool { - return strings.ToLower(string(i)) == "process" -} - // IsValid indicates if an isolation technology is valid func (i Isolation) IsValid() bool { return i.IsDefault() || i.IsHyperV() || i.IsProcess() diff --git a/vendor/github.com/docker/docker/api/types/container/waitcondition.go b/vendor/github.com/docker/docker/api/types/container/waitcondition.go index 64820fe358..cd8311f99c 100644 --- a/vendor/github.com/docker/docker/api/types/container/waitcondition.go +++ b/vendor/github.com/docker/docker/api/types/container/waitcondition.go @@ -1,4 +1,4 @@ -package container +package container // import "github.com/docker/docker/api/types/container" // WaitCondition is a type used to specify a container state for which // to wait. diff --git a/vendor/github.com/docker/docker/api/types/events/events.go b/vendor/github.com/docker/docker/api/types/events/events.go index e292565b6c..027c6edb72 100644 --- a/vendor/github.com/docker/docker/api/types/events/events.go +++ b/vendor/github.com/docker/docker/api/types/events/events.go @@ -1,4 +1,4 @@ -package events +package events // import "github.com/docker/docker/api/types/events" const ( // ContainerEventType is the event type that containers generate diff --git a/vendor/github.com/docker/docker/api/types/filters/parse.go b/vendor/github.com/docker/docker/api/types/filters/parse.go index d45d0528fb..d8f19ae227 100644 --- a/vendor/github.com/docker/docker/api/types/filters/parse.go +++ b/vendor/github.com/docker/docker/api/types/filters/parse.go @@ -1,7 +1,7 @@ /*Package filters provides tools for encoding a mapping of keys to a set of multiple values. */ -package filters +package filters // import "github.com/docker/docker/api/types/filters" import ( "encoding/json" @@ -323,6 +323,22 @@ func (args Args) WalkValues(field string, op func(value string) error) error { return nil } +// Clone returns a copy of args. +func (args Args) Clone() (newArgs Args) { + newArgs.fields = make(map[string]map[string]bool, len(args.fields)) + for k, m := range args.fields { + var mm map[string]bool + if m != nil { + mm = make(map[string]bool, len(m)) + for kk, v := range m { + mm[kk] = v + } + } + newArgs.fields[k] = mm + } + return newArgs +} + func deprecatedArgs(d map[string][]string) map[string]map[string]bool { m := map[string]map[string]bool{} for k, v := range d { diff --git a/vendor/github.com/docker/docker/api/types/image/image_history.go b/vendor/github.com/docker/docker/api/types/image/image_history.go index 0dd30c729a..d6b354bcdf 100644 --- a/vendor/github.com/docker/docker/api/types/image/image_history.go +++ b/vendor/github.com/docker/docker/api/types/image/image_history.go @@ -7,7 +7,7 @@ package image // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// HistoryResponseItem history response item +// HistoryResponseItem individual image layer information in response to ImageHistory operation // swagger:model HistoryResponseItem type HistoryResponseItem struct { diff --git a/vendor/github.com/docker/docker/api/types/mount/mount.go b/vendor/github.com/docker/docker/api/types/mount/mount.go index b7d133cd84..ab4446b38f 100644 --- a/vendor/github.com/docker/docker/api/types/mount/mount.go +++ b/vendor/github.com/docker/docker/api/types/mount/mount.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/api/types/mount" import ( "os" @@ -79,7 +79,8 @@ const ( // BindOptions defines options specific to mounts of type "bind". type BindOptions struct { - Propagation Propagation `json:",omitempty"` + Propagation Propagation `json:",omitempty"` + NonRecursive bool `json:",omitempty"` } // VolumeOptions represents the options for a mount of type volume. diff --git a/vendor/github.com/docker/docker/api/types/network/network.go b/vendor/github.com/docker/docker/api/types/network/network.go index 7c7dbacc85..71e97338fd 100644 --- a/vendor/github.com/docker/docker/api/types/network/network.go +++ b/vendor/github.com/docker/docker/api/types/network/network.go @@ -1,4 +1,8 @@ -package network +package network // import "github.com/docker/docker/api/types/network" +import ( + "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/errdefs" +) // Address represents an IP address type Address struct { @@ -106,3 +110,18 @@ type NetworkingConfig struct { type ConfigReference struct { Network string } + +var acceptedFilters = map[string]bool{ + "dangling": true, + "driver": true, + "id": true, + "label": true, + "name": true, + "scope": true, + "type": true, +} + +// ValidateFilters validates the list of filter args with the available filters. +func ValidateFilters(filter filters.Args) error { + return errdefs.InvalidParameter(filter.Validate(acceptedFilters)) +} diff --git a/vendor/github.com/docker/docker/api/types/plugin.go b/vendor/github.com/docker/docker/api/types/plugin.go index cab333e01a..abae48b9ab 100644 --- a/vendor/github.com/docker/docker/api/types/plugin.go +++ b/vendor/github.com/docker/docker/api/types/plugin.go @@ -121,6 +121,9 @@ type PluginConfigArgs struct { // swagger:model PluginConfigInterface type PluginConfigInterface struct { + // Protocol to use for clients connecting to the plugin. + ProtocolScheme string `json:"ProtocolScheme,omitempty"` + // socket // Required: true Socket string `json:"Socket"` diff --git a/vendor/github.com/docker/docker/api/types/plugin_responses.go b/vendor/github.com/docker/docker/api/types/plugin_responses.go index 18f743fcde..60d1fb5ad8 100644 --- a/vendor/github.com/docker/docker/api/types/plugin_responses.go +++ b/vendor/github.com/docker/docker/api/types/plugin_responses.go @@ -1,4 +1,4 @@ -package types +package types // import "github.com/docker/docker/api/types" import ( "encoding/json" diff --git a/vendor/github.com/docker/docker/api/types/port.go b/vendor/github.com/docker/docker/api/types/port.go index ad52d46d56..d91234744c 100644 --- a/vendor/github.com/docker/docker/api/types/port.go +++ b/vendor/github.com/docker/docker/api/types/port.go @@ -7,7 +7,7 @@ package types // swagger:model Port type Port struct { - // IP + // Host IP address that the container's port is mapped to IP string `json:"IP,omitempty"` // Port on the container diff --git a/vendor/github.com/docker/docker/api/types/registry/authenticate.go b/vendor/github.com/docker/docker/api/types/registry/authenticate.go index 42cac4430a..f0a2113e40 100644 --- a/vendor/github.com/docker/docker/api/types/registry/authenticate.go +++ b/vendor/github.com/docker/docker/api/types/registry/authenticate.go @@ -1,4 +1,4 @@ -package registry +package registry // import "github.com/docker/docker/api/types/registry" // ---------------------------------------------------------------------------- // DO NOT EDIT THIS FILE diff --git a/vendor/github.com/docker/docker/api/types/registry/registry.go b/vendor/github.com/docker/docker/api/types/registry/registry.go index b98a943a13..8789ad3b32 100644 --- a/vendor/github.com/docker/docker/api/types/registry/registry.go +++ b/vendor/github.com/docker/docker/api/types/registry/registry.go @@ -1,4 +1,4 @@ -package registry +package registry // import "github.com/docker/docker/api/types/registry" import ( "encoding/json" diff --git a/vendor/github.com/docker/docker/api/types/seccomp.go b/vendor/github.com/docker/docker/api/types/seccomp.go index 7d62c9a43f..2259c6be1e 100644 --- a/vendor/github.com/docker/docker/api/types/seccomp.go +++ b/vendor/github.com/docker/docker/api/types/seccomp.go @@ -1,4 +1,4 @@ -package types +package types // import "github.com/docker/docker/api/types" // Seccomp represents the config for a seccomp profile for syscall restriction. type Seccomp struct { @@ -77,8 +77,9 @@ type Arg struct { // Filter is used to conditionally apply Seccomp rules type Filter struct { - Caps []string `json:"caps,omitempty"` - Arches []string `json:"arches,omitempty"` + Caps []string `json:"caps,omitempty"` + Arches []string `json:"arches,omitempty"` + MinKernel string `json:"minKernel,omitempty"` } // Syscall is used to match a group of syscalls in Seccomp diff --git a/vendor/github.com/docker/docker/api/types/stats.go b/vendor/github.com/docker/docker/api/types/stats.go index 7ca76a5b63..20daebed14 100644 --- a/vendor/github.com/docker/docker/api/types/stats.go +++ b/vendor/github.com/docker/docker/api/types/stats.go @@ -1,6 +1,6 @@ // Package types is used for API stability in the types and response to the // consumers of the API stats endpoint. -package types +package types // import "github.com/docker/docker/api/types" import "time" @@ -120,7 +120,7 @@ type NetworkStats struct { RxBytes uint64 `json:"rx_bytes"` // Packets received. Windows and Linux. RxPackets uint64 `json:"rx_packets"` - // Received errors. Not used on Windows. Note that we dont `omitempty` this + // Received errors. Not used on Windows. Note that we don't `omitempty` this // field as it is expected in the >=v1.21 API stats structure. RxErrors uint64 `json:"rx_errors"` // Incoming packets dropped. Windows and Linux. @@ -129,7 +129,7 @@ type NetworkStats struct { TxBytes uint64 `json:"tx_bytes"` // Packets sent. Windows and Linux. TxPackets uint64 `json:"tx_packets"` - // Sent errors. Not used on Windows. Note that we dont `omitempty` this + // Sent errors. Not used on Windows. Note that we don't `omitempty` this // field as it is expected in the >=v1.21 API stats structure. TxErrors uint64 `json:"tx_errors"` // Outgoing packets dropped. Windows and Linux. diff --git a/vendor/github.com/docker/docker/api/types/strslice/strslice.go b/vendor/github.com/docker/docker/api/types/strslice/strslice.go index bad493fb89..82921cebc1 100644 --- a/vendor/github.com/docker/docker/api/types/strslice/strslice.go +++ b/vendor/github.com/docker/docker/api/types/strslice/strslice.go @@ -1,4 +1,4 @@ -package strslice +package strslice // import "github.com/docker/docker/api/types/strslice" import "encoding/json" diff --git a/vendor/github.com/docker/docker/api/types/swarm/common.go b/vendor/github.com/docker/docker/api/types/swarm/common.go index 2834cf2022..ef020f458b 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/common.go +++ b/vendor/github.com/docker/docker/api/types/swarm/common.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import "time" diff --git a/vendor/github.com/docker/docker/api/types/swarm/config.go b/vendor/github.com/docker/docker/api/types/swarm/config.go index 0fb021ce92..16202ccce6 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/config.go +++ b/vendor/github.com/docker/docker/api/types/swarm/config.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import "os" @@ -13,6 +13,10 @@ type Config struct { type ConfigSpec struct { Annotations Data []byte `json:",omitempty"` + + // Templating controls whether and how to evaluate the config payload as + // a template. If it is not set, no templating is used. + Templating *Driver `json:",omitempty"` } // ConfigReferenceFileTarget is a file target in a config reference @@ -23,9 +27,14 @@ type ConfigReferenceFileTarget struct { Mode os.FileMode } +// ConfigReferenceRuntimeTarget is a target for a config specifying that it +// isn't mounted into the container but instead has some other purpose. +type ConfigReferenceRuntimeTarget struct{} + // ConfigReference is a reference to a config in swarm type ConfigReference struct { - File *ConfigReferenceFileTarget + File *ConfigReferenceFileTarget `json:",omitempty"` + Runtime *ConfigReferenceRuntimeTarget `json:",omitempty"` ConfigID string ConfigName string } diff --git a/vendor/github.com/docker/docker/api/types/swarm/container.go b/vendor/github.com/docker/docker/api/types/swarm/container.go index 6f8b45f6bb..48190c1762 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/container.go +++ b/vendor/github.com/docker/docker/api/types/swarm/container.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import ( "time" @@ -33,6 +33,7 @@ type SELinuxContext struct { // CredentialSpec for managed service account (Windows only) type CredentialSpec struct { + Config string File string Registry string } @@ -55,6 +56,7 @@ type ContainerSpec struct { User string `json:",omitempty"` Groups []string `json:",omitempty"` Privileges *Privileges `json:",omitempty"` + Init *bool `json:",omitempty"` StopSignal string `json:",omitempty"` TTY bool `json:",omitempty"` OpenStdin bool `json:",omitempty"` @@ -65,8 +67,10 @@ type ContainerSpec struct { // The format of extra hosts on swarmkit is specified in: // http://man7.org/linux/man-pages/man5/hosts.5.html // IP_address canonical_hostname [aliases...] - Hosts []string `json:",omitempty"` - DNSConfig *DNSConfig `json:",omitempty"` - Secrets []*SecretReference `json:",omitempty"` - Configs []*ConfigReference `json:",omitempty"` + Hosts []string `json:",omitempty"` + DNSConfig *DNSConfig `json:",omitempty"` + Secrets []*SecretReference `json:",omitempty"` + Configs []*ConfigReference `json:",omitempty"` + Isolation container.Isolation `json:",omitempty"` + Sysctls map[string]string `json:",omitempty"` } diff --git a/vendor/github.com/docker/docker/api/types/swarm/network.go b/vendor/github.com/docker/docker/api/types/swarm/network.go index 97c484e14c..98ef3284d1 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/network.go +++ b/vendor/github.com/docker/docker/api/types/swarm/network.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import ( "github.com/docker/docker/api/types/network" @@ -62,6 +62,8 @@ const ( PortConfigProtocolTCP PortConfigProtocol = "tcp" // PortConfigProtocolUDP UDP PortConfigProtocolUDP PortConfigProtocol = "udp" + // PortConfigProtocolSCTP SCTP + PortConfigProtocolSCTP PortConfigProtocol = "sctp" ) // EndpointVirtualIP represents the virtual ip of a port. diff --git a/vendor/github.com/docker/docker/api/types/swarm/node.go b/vendor/github.com/docker/docker/api/types/swarm/node.go index 28c6851e9c..1e30f5fa10 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/node.go +++ b/vendor/github.com/docker/docker/api/types/swarm/node.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" // Node represents a node. type Node struct { diff --git a/vendor/github.com/docker/docker/api/types/swarm/runtime.go b/vendor/github.com/docker/docker/api/types/swarm/runtime.go index c4c731dc82..0c77403ccf 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/runtime.go +++ b/vendor/github.com/docker/docker/api/types/swarm/runtime.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" // RuntimeType is the type of runtime used for the TaskSpec type RuntimeType string @@ -11,9 +11,17 @@ const ( RuntimeContainer RuntimeType = "container" // RuntimePlugin is the plugin based runtime RuntimePlugin RuntimeType = "plugin" + // RuntimeNetworkAttachment is the network attachment runtime + RuntimeNetworkAttachment RuntimeType = "attachment" // RuntimeURLContainer is the proto url for the container type RuntimeURLContainer RuntimeURL = "types.docker.com/RuntimeContainer" // RuntimeURLPlugin is the proto url for the plugin type RuntimeURLPlugin RuntimeURL = "types.docker.com/RuntimePlugin" ) + +// NetworkAttachmentSpec represents the runtime spec type for network +// attachment tasks +type NetworkAttachmentSpec struct { + ContainerID string +} diff --git a/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go b/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go index 47ae234ef3..98c2806c31 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go +++ b/vendor/github.com/docker/docker/api/types/swarm/runtime/gen.go @@ -1,3 +1,3 @@ //go:generate protoc -I . --gogofast_out=import_path=github.com/docker/docker/api/types/swarm/runtime:. plugin.proto -package runtime +package runtime // import "github.com/docker/docker/api/types/swarm/runtime" diff --git a/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto b/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto index 06eb7ba650..6d63b7783f 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto +++ b/vendor/github.com/docker/docker/api/types/swarm/runtime/plugin.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +option go_package = "github.com/docker/docker/api/types/swarm/runtime;runtime"; + // PluginSpec defines the base payload which clients can specify for creating // a service with the plugin runtime. message PluginSpec { diff --git a/vendor/github.com/docker/docker/api/types/swarm/secret.go b/vendor/github.com/docker/docker/api/types/swarm/secret.go index f9b1e92669..d5213ec981 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/secret.go +++ b/vendor/github.com/docker/docker/api/types/swarm/secret.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import "os" @@ -14,6 +14,10 @@ type SecretSpec struct { Annotations Data []byte `json:",omitempty"` Driver *Driver `json:",omitempty"` // name of the secrets driver used to fetch the secret's value from an external secret store + + // Templating controls whether and how to evaluate the secret payload as + // a template. If it is not set, no templating is used. + Templating *Driver `json:",omitempty"` } // SecretReferenceFileTarget is a file target in a secret reference diff --git a/vendor/github.com/docker/docker/api/types/swarm/service.go b/vendor/github.com/docker/docker/api/types/swarm/service.go index fa31a7ec86..abf192e759 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/service.go +++ b/vendor/github.com/docker/docker/api/types/swarm/service.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import "time" diff --git a/vendor/github.com/docker/docker/api/types/swarm/swarm.go b/vendor/github.com/docker/docker/api/types/swarm/swarm.go index b65fa86dac..484cd0be7f 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/swarm.go +++ b/vendor/github.com/docker/docker/api/types/swarm/swarm.go @@ -1,6 +1,8 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" -import "time" +import ( + "time" +) // ClusterInfo represents info about the cluster for outputting in "info" // it contains the same information as "Swarm", but without the JoinTokens @@ -10,6 +12,9 @@ type ClusterInfo struct { Spec Spec TLSInfo TLSInfo RootRotationInProgress bool + DefaultAddrPool []string + SubnetSize uint32 + DataPathPort uint32 } // Swarm represents a swarm. @@ -149,10 +154,13 @@ type InitRequest struct { ListenAddr string AdvertiseAddr string DataPathAddr string + DataPathPort uint32 ForceNewCluster bool Spec Spec AutoLockManagers bool Availability NodeAvailability + DefaultAddrPool []string + SubnetSize uint32 } // JoinRequest is the request used to join a swarm. diff --git a/vendor/github.com/docker/docker/api/types/swarm/task.go b/vendor/github.com/docker/docker/api/types/swarm/task.go index ff11b07e74..d5a57df5db 100644 --- a/vendor/github.com/docker/docker/api/types/swarm/task.go +++ b/vendor/github.com/docker/docker/api/types/swarm/task.go @@ -1,4 +1,4 @@ -package swarm +package swarm // import "github.com/docker/docker/api/types/swarm" import ( "time" @@ -36,6 +36,10 @@ const ( TaskStateFailed TaskState = "failed" // TaskStateRejected REJECTED TaskStateRejected TaskState = "rejected" + // TaskStateRemove REMOVE + TaskStateRemove TaskState = "remove" + // TaskStateOrphaned ORPHANED + TaskStateOrphaned TaskState = "orphaned" ) // Task represents a task. @@ -56,10 +60,13 @@ type Task struct { // TaskSpec represents the spec of a task. type TaskSpec struct { - // ContainerSpec and PluginSpec are mutually exclusive. - // PluginSpec will only be used when the `Runtime` field is set to `plugin` - ContainerSpec *ContainerSpec `json:",omitempty"` - PluginSpec *runtime.PluginSpec `json:",omitempty"` + // ContainerSpec, NetworkAttachmentSpec, and PluginSpec are mutually exclusive. + // PluginSpec is only used when the `Runtime` field is set to `plugin` + // NetworkAttachmentSpec is used if the `Runtime` field is set to + // `attachment`. + ContainerSpec *ContainerSpec `json:",omitempty"` + PluginSpec *runtime.PluginSpec `json:",omitempty"` + NetworkAttachmentSpec *NetworkAttachmentSpec `json:",omitempty"` Resources *ResourceRequirements `json:",omitempty"` RestartPolicy *RestartPolicy `json:",omitempty"` @@ -120,6 +127,7 @@ type ResourceRequirements struct { type Placement struct { Constraints []string `json:",omitempty"` Preferences []PlacementPreference `json:",omitempty"` + MaxReplicas uint64 `json:",omitempty"` // Platforms stores all the platforms that the image can run on. // This field is used in the platform filter for scheduling. If empty, @@ -162,19 +170,19 @@ const ( // TaskStatus represents the status of a task. type TaskStatus struct { - Timestamp time.Time `json:",omitempty"` - State TaskState `json:",omitempty"` - Message string `json:",omitempty"` - Err string `json:",omitempty"` - ContainerStatus ContainerStatus `json:",omitempty"` - PortStatus PortStatus `json:",omitempty"` + Timestamp time.Time `json:",omitempty"` + State TaskState `json:",omitempty"` + Message string `json:",omitempty"` + Err string `json:",omitempty"` + ContainerStatus *ContainerStatus `json:",omitempty"` + PortStatus PortStatus `json:",omitempty"` } // ContainerStatus represents the status of a container. type ContainerStatus struct { - ContainerID string `json:",omitempty"` - PID int `json:",omitempty"` - ExitCode int `json:",omitempty"` + ContainerID string + PID int + ExitCode int } // PortStatus represents the port status of a task's host ports whose diff --git a/vendor/github.com/docker/docker/api/types/time/duration_convert.go b/vendor/github.com/docker/docker/api/types/time/duration_convert.go index 63e1eec19e..84b6f07322 100644 --- a/vendor/github.com/docker/docker/api/types/time/duration_convert.go +++ b/vendor/github.com/docker/docker/api/types/time/duration_convert.go @@ -1,4 +1,4 @@ -package time +package time // import "github.com/docker/docker/api/types/time" import ( "strconv" diff --git a/vendor/github.com/docker/docker/api/types/time/timestamp.go b/vendor/github.com/docker/docker/api/types/time/timestamp.go index ed9c1168b7..ea3495efeb 100644 --- a/vendor/github.com/docker/docker/api/types/time/timestamp.go +++ b/vendor/github.com/docker/docker/api/types/time/timestamp.go @@ -1,4 +1,4 @@ -package time +package time // import "github.com/docker/docker/api/types/time" import ( "fmt" @@ -82,11 +82,14 @@ func GetTimestamp(value string, reference time.Time) (string, error) { } if err != nil { - // if there is a `-` then it's an RFC3339 like timestamp otherwise assume unixtimestamp + // if there is a `-` then it's an RFC3339 like timestamp if strings.Contains(value, "-") { return "", err // was probably an RFC3339 like timestamp but the parser failed with an error } - return value, nil // unixtimestamp in and out case (meaning: the value passed at the command line is already in the right format for passing to the server) + if _, _, err := parseTimestamp(value); err != nil { + return "", fmt.Errorf("failed to parse value as time or duration: %q", value) + } + return value, nil // unix timestamp in and out case (meaning: the value passed at the command line is already in the right format for passing to the server) } return fmt.Sprintf("%d.%09d", t.Unix(), int64(t.Nanosecond())), nil @@ -104,6 +107,10 @@ func ParseTimestamps(value string, def int64) (int64, int64, error) { if value == "" { return def, 0, nil } + return parseTimestamp(value) +} + +func parseTimestamp(value string) (int64, int64, error) { sa := strings.SplitN(value, ".", 2) s, err := strconv.ParseInt(sa[0], 10, 64) if err != nil { diff --git a/vendor/github.com/docker/docker/api/types/types.go b/vendor/github.com/docker/docker/api/types/types.go index f7ac772971..ed555aad2b 100644 --- a/vendor/github.com/docker/docker/api/types/types.go +++ b/vendor/github.com/docker/docker/api/types/types.go @@ -1,4 +1,4 @@ -package types +package types // import "github.com/docker/docker/api/types" import ( "errors" @@ -102,14 +102,27 @@ type ContainerStats struct { // Ping contains response of Engine API: // GET "/_ping" type Ping struct { - APIVersion string - OSType string - Experimental bool + APIVersion string + OSType string + Experimental bool + BuilderVersion BuilderVersion +} + +// ComponentVersion describes the version information for a specific component. +type ComponentVersion struct { + Name string + Version string + Details map[string]string `json:",omitempty"` } // Version contains response of Engine API: // GET "/version" type Version struct { + Platform struct{ Name string } `json:",omitempty"` + Components []ComponentVersion `json:",omitempty"` + + // The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility + Version string APIVersion string `json:"ApiVersion"` MinAPIVersion string `json:"MinAPIVersion,omitempty"` @@ -133,6 +146,7 @@ type Commit struct { // GET "/info" type Info struct { ID string + Builder BuilderVersion Containers int ContainersRunning int ContainersPaused int @@ -145,10 +159,12 @@ type Info struct { MemoryLimit bool SwapLimit bool KernelMemory bool + KernelMemoryTCP bool CPUCfsPeriod bool `json:"CpuCfsPeriod"` CPUCfsQuota bool `json:"CpuCfsQuota"` CPUShares bool CPUSet bool + PidsLimit bool IPv4Forwarding bool BridgeNfIptables bool BridgeNfIP6tables bool `json:"BridgeNfIp6tables"` @@ -192,6 +208,8 @@ type Info struct { RuncCommit Commit InitCommit Commit SecurityOptions []string + ProductLicense string `json:",omitempty"` + Warnings []string } // KeyValue holds a key/value pair @@ -500,7 +518,8 @@ type DiskUsage struct { Images []*ImageSummary Containers []*Container Volumes []*Volume - BuilderSize int64 + BuildCache []*BuildCache + BuilderSize int64 // deprecated } // ContainersPruneReport contains the response for Engine API: @@ -527,6 +546,7 @@ type ImagesPruneReport struct { // BuildCachePruneReport contains the response for Engine API: // POST "/build/prune" type BuildCachePruneReport struct { + CachesDeleted []string SpaceReclaimed uint64 } @@ -573,3 +593,24 @@ type PushResult struct { type BuildResult struct { ID string } + +// BuildCache contains information about a build cache record +type BuildCache struct { + ID string + Parent string + Type string + Description string + InUse bool + Shared bool + Size int64 + CreatedAt time.Time + LastUsedAt *time.Time + UsageCount int +} + +// BuildCachePruneOptions hold parameters to prune the build cache +type BuildCachePruneOptions struct { + All bool + KeepStorage int64 + Filters filters.Args +} diff --git a/vendor/github.com/docker/docker/api/types/versions/compare.go b/vendor/github.com/docker/docker/api/types/versions/compare.go index 611d4fed66..8ccb0aa92e 100644 --- a/vendor/github.com/docker/docker/api/types/versions/compare.go +++ b/vendor/github.com/docker/docker/api/types/versions/compare.go @@ -1,4 +1,4 @@ -package versions +package versions // import "github.com/docker/docker/api/types/versions" import ( "strconv" diff --git a/vendor/github.com/docker/docker/api/types/volume/volumes_create.go b/vendor/github.com/docker/docker/api/types/volume/volume_create.go similarity index 88% rename from vendor/github.com/docker/docker/api/types/volume/volumes_create.go rename to vendor/github.com/docker/docker/api/types/volume/volume_create.go index 9f70e43ca4..f12e48612c 100644 --- a/vendor/github.com/docker/docker/api/types/volume/volumes_create.go +++ b/vendor/github.com/docker/docker/api/types/volume/volume_create.go @@ -7,9 +7,9 @@ package volume // See hack/generate-swagger-api.sh // ---------------------------------------------------------------------------- -// VolumesCreateBody volumes create body -// swagger:model VolumesCreateBody -type VolumesCreateBody struct { +// VolumeCreateBody Volume configuration +// swagger:model VolumeCreateBody +type VolumeCreateBody struct { // Name of the volume driver to use. // Required: true diff --git a/vendor/github.com/docker/docker/api/types/volume/volumes_list.go b/vendor/github.com/docker/docker/api/types/volume/volume_list.go similarity index 83% rename from vendor/github.com/docker/docker/api/types/volume/volumes_list.go rename to vendor/github.com/docker/docker/api/types/volume/volume_list.go index 833dad9330..020198f737 100644 --- a/vendor/github.com/docker/docker/api/types/volume/volumes_list.go +++ b/vendor/github.com/docker/docker/api/types/volume/volume_list.go @@ -9,9 +9,9 @@ package volume import "github.com/docker/docker/api/types" -// VolumesListOKBody volumes list o k body -// swagger:model VolumesListOKBody -type VolumesListOKBody struct { +// VolumeListOKBody Volume list response +// swagger:model VolumeListOKBody +type VolumeListOKBody struct { // List of volumes // Required: true diff --git a/vendor/github.com/docker/docker/client/README.md b/vendor/github.com/docker/docker/client/README.md index 059dfb3ce7..992f18117d 100644 --- a/vendor/github.com/docker/docker/client/README.md +++ b/vendor/github.com/docker/docker/client/README.md @@ -16,7 +16,7 @@ import ( ) func main() { - cli, err := client.NewEnvClient() + cli, err := client.NewClientWithOpts(client.FromEnv) if err != nil { panic(err) } diff --git a/vendor/github.com/docker/docker/client/build_cancel.go b/vendor/github.com/docker/docker/client/build_cancel.go new file mode 100644 index 0000000000..74df495089 --- /dev/null +++ b/vendor/github.com/docker/docker/client/build_cancel.go @@ -0,0 +1,20 @@ +package client // import "github.com/docker/docker/client" + +import ( + "context" + "net/url" +) + +// BuildCancel requests the daemon to cancel ongoing build request +func (cli *Client) BuildCancel(ctx context.Context, id string) error { + query := url.Values{} + query.Set("id", id) + + serverResp, err := cli.post(ctx, "/build/cancel", query, nil, nil) + if err != nil { + return err + } + defer ensureReaderClosed(serverResp) + + return nil +} diff --git a/vendor/github.com/docker/docker/client/build_prune.go b/vendor/github.com/docker/docker/client/build_prune.go index ccab115d33..42bbf99ef1 100644 --- a/vendor/github.com/docker/docker/client/build_prune.go +++ b/vendor/github.com/docker/docker/client/build_prune.go @@ -1,22 +1,37 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" + "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" + "github.com/docker/docker/api/types/filters" + "github.com/pkg/errors" ) // BuildCachePrune requests the daemon to delete unused cache data -func (cli *Client) BuildCachePrune(ctx context.Context) (*types.BuildCachePruneReport, error) { +func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) { if err := cli.NewVersionError("1.31", "build prune"); err != nil { return nil, err } report := types.BuildCachePruneReport{} - serverResp, err := cli.post(ctx, "/build/prune", nil, nil, nil) + query := url.Values{} + if opts.All { + query.Set("all", "1") + } + query.Set("keep-storage", fmt.Sprintf("%d", opts.KeepStorage)) + filters, err := filters.ToJSON(opts.Filters) + if err != nil { + return nil, errors.Wrap(err, "prune could not marshal filters option") + } + query.Set("filters", filters) + + serverResp, err := cli.post(ctx, "/build/prune", query, nil, nil) + if err != nil { return nil, err } diff --git a/vendor/github.com/docker/docker/client/checkpoint_create.go b/vendor/github.com/docker/docker/client/checkpoint_create.go index 0effe498be..921024fe4f 100644 --- a/vendor/github.com/docker/docker/client/checkpoint_create.go +++ b/vendor/github.com/docker/docker/client/checkpoint_create.go @@ -1,8 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // CheckpointCreate creates a checkpoint from the given container with the given name diff --git a/vendor/github.com/docker/docker/client/checkpoint_delete.go b/vendor/github.com/docker/docker/client/checkpoint_delete.go index e6e75588b1..54f55fa76e 100644 --- a/vendor/github.com/docker/docker/client/checkpoint_delete.go +++ b/vendor/github.com/docker/docker/client/checkpoint_delete.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // CheckpointDelete deletes the checkpoint with the given name from the given container diff --git a/vendor/github.com/docker/docker/client/checkpoint_list.go b/vendor/github.com/docker/docker/client/checkpoint_list.go index 9835bad5ca..2b73fb553f 100644 --- a/vendor/github.com/docker/docker/client/checkpoint_list.go +++ b/vendor/github.com/docker/docker/client/checkpoint_list.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // CheckpointList returns the checkpoints of the given container in the docker host diff --git a/vendor/github.com/docker/docker/client/client.go b/vendor/github.com/docker/docker/client/client.go index 893124853f..f174d3ce71 100644 --- a/vendor/github.com/docker/docker/client/client.go +++ b/vendor/github.com/docker/docker/client/client.go @@ -23,7 +23,7 @@ For example, to list running containers (the equivalent of "docker ps"): ) func main() { - cli, err := client.NewEnvClient() + cli, err := client.NewClientWithOpts(client.FromEnv) if err != nil { panic(err) } @@ -39,24 +39,22 @@ For example, to list running containers (the equivalent of "docker ps"): } */ -package client +package client // import "github.com/docker/docker/client" import ( - "errors" + "context" "fmt" + "net" "net/http" "net/url" - "os" "path" - "path/filepath" "strings" "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/docker/go-connections/sockets" - "github.com/docker/go-connections/tlsconfig" - "golang.org/x/net/context" + "github.com/pkg/errors" ) // ErrRedirect is the error returned by checkRedirect when the request is non-GET. @@ -102,99 +100,62 @@ func CheckRedirect(req *http.Request, via []*http.Request) error { return ErrRedirect } -// NewEnvClient initializes a new API client based on environment variables. -// Use DOCKER_HOST to set the url to the docker server. -// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest. -// Use DOCKER_CERT_PATH to load the TLS certificates from. -// Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default. -func NewEnvClient() (*Client, error) { - var client *http.Client - if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" { - options := tlsconfig.Options{ - CAFile: filepath.Join(dockerCertPath, "ca.pem"), - CertFile: filepath.Join(dockerCertPath, "cert.pem"), - KeyFile: filepath.Join(dockerCertPath, "key.pem"), - InsecureSkipVerify: os.Getenv("DOCKER_TLS_VERIFY") == "", - } - tlsc, err := tlsconfig.Client(options) - if err != nil { - return nil, err - } - - client = &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: tlsc, - }, - CheckRedirect: CheckRedirect, - } - } - - host := os.Getenv("DOCKER_HOST") - if host == "" { - host = DefaultDockerHost - } - version := os.Getenv("DOCKER_API_VERSION") - if version == "" { - version = api.DefaultVersion - } - - cli, err := NewClient(host, version, client, nil) - if err != nil { - return cli, err - } - if os.Getenv("DOCKER_API_VERSION") != "" { - cli.manualOverride = true - } - return cli, nil -} - -// NewClient initializes a new API client for the given host and API version. -// It uses the given http client as transport. +// NewClientWithOpts initializes a new API client with default values. It takes functors +// to modify values when creating it, like `NewClientWithOpts(WithVersion(…))` // It also initializes the custom http headers to add to each request. // // It won't send any version information if the version number is empty. It is // highly recommended that you set a version or your client may break if the // server is upgraded. -func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) { - hostURL, err := ParseHostURL(host) +func NewClientWithOpts(ops ...func(*Client) error) (*Client, error) { + client, err := defaultHTTPClient(DefaultDockerHost) if err != nil { return nil, err } + c := &Client{ + host: DefaultDockerHost, + version: api.DefaultVersion, + client: client, + proto: defaultProto, + addr: defaultAddr, + } - if client != nil { - if _, ok := client.Transport.(http.RoundTripper); !ok { - return nil, fmt.Errorf("unable to verify TLS configuration, invalid transport %v", client.Transport) - } - } else { - transport := new(http.Transport) - sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host) - client = &http.Client{ - Transport: transport, - CheckRedirect: CheckRedirect, + for _, op := range ops { + if err := op(c); err != nil { + return nil, err } } - scheme := "http" - tlsConfig := resolveTLSConfig(client.Transport) - if tlsConfig != nil { - // TODO(stevvooe): This isn't really the right way to write clients in Go. - // `NewClient` should probably only take an `*http.Client` and work from there. - // Unfortunately, the model of having a host-ish/url-thingy as the connection - // string has us confusing protocol and transport layers. We continue doing - // this to avoid breaking existing clients but this should be addressed. - scheme = "https" + if _, ok := c.client.Transport.(http.RoundTripper); !ok { + return nil, fmt.Errorf("unable to verify TLS configuration, invalid transport %v", c.client.Transport) + } + if c.scheme == "" { + c.scheme = "http" + + tlsConfig := resolveTLSConfig(c.client.Transport) + if tlsConfig != nil { + // TODO(stevvooe): This isn't really the right way to write clients in Go. + // `NewClient` should probably only take an `*http.Client` and work from there. + // Unfortunately, the model of having a host-ish/url-thingy as the connection + // string has us confusing protocol and transport layers. We continue doing + // this to avoid breaking existing clients but this should be addressed. + c.scheme = "https" + } } - // TODO: store URL instead of proto/addr/basePath - return &Client{ - scheme: scheme, - host: host, - proto: hostURL.Scheme, - addr: hostURL.Host, - basePath: hostURL.Path, - client: client, - version: version, - customHTTPHeaders: httpHeaders, + return c, nil +} + +func defaultHTTPClient(host string) (*http.Client, error) { + url, err := ParseHostURL(host) + if err != nil { + return nil, err + } + transport := new(http.Transport) + sockets.ConfigureTransport(transport, url.Scheme, url.Host) + return &http.Client{ + Transport: transport, + CheckRedirect: CheckRedirect, }, nil } @@ -259,15 +220,9 @@ func (cli *Client) DaemonHost() string { return cli.host } -// ParseHost parses a url string, validates the strings is a host url, and returns -// the parsed host as: protocol, address, and base path -// Deprecated: use ParseHostURL -func ParseHost(host string) (string, string, string, error) { - hostURL, err := ParseHostURL(host) - if err != nil { - return "", "", "", err - } - return hostURL.Scheme, hostURL.Host, hostURL.Path, nil +// HTTPClient returns a copy of the HTTP client bound to the server +func (cli *Client) HTTPClient() *http.Client { + return &*cli.client } // ParseHostURL parses a url string, validates the string is a host url, and @@ -305,6 +260,20 @@ func (cli *Client) CustomHTTPHeaders() map[string]string { } // SetCustomHTTPHeaders that will be set on every HTTP request made by the client. +// Deprecated: use WithHTTPHeaders when creating the client. func (cli *Client) SetCustomHTTPHeaders(headers map[string]string) { cli.customHTTPHeaders = headers } + +// Dialer returns a dialer for a raw stream connection, with HTTP/1.1 header, that can be used for proxying the daemon connection. +// Used by `docker dial-stdio` (docker/cli#889). +func (cli *Client) Dialer() func(context.Context) (net.Conn, error) { + return func(ctx context.Context) (net.Conn, error) { + if transport, ok := cli.client.Transport.(*http.Transport); ok { + if transport.DialContext != nil && transport.TLSClientConfig == nil { + return transport.DialContext(ctx, cli.proto, cli.addr) + } + } + return fallbackDial(cli.proto, cli.addr, resolveTLSConfig(cli.client.Transport)) + } +} diff --git a/vendor/github.com/docker/docker/client/client_deprecated.go b/vendor/github.com/docker/docker/client/client_deprecated.go new file mode 100644 index 0000000000..54cdfc29a8 --- /dev/null +++ b/vendor/github.com/docker/docker/client/client_deprecated.go @@ -0,0 +1,23 @@ +package client + +import "net/http" + +// NewClient initializes a new API client for the given host and API version. +// It uses the given http client as transport. +// It also initializes the custom http headers to add to each request. +// +// It won't send any version information if the version number is empty. It is +// highly recommended that you set a version or your client may break if the +// server is upgraded. +// Deprecated: use NewClientWithOpts +func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) { + return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders)) +} + +// NewEnvClient initializes a new API client based on environment variables. +// See FromEnv for a list of support environment variables. +// +// Deprecated: use NewClientWithOpts(FromEnv) +func NewEnvClient() (*Client, error) { + return NewClientWithOpts(FromEnv) +} diff --git a/vendor/github.com/docker/docker/client/client_unix.go b/vendor/github.com/docker/docker/client/client_unix.go index 89de892c85..3d24470ba3 100644 --- a/vendor/github.com/docker/docker/client/client_unix.go +++ b/vendor/github.com/docker/docker/client/client_unix.go @@ -1,6 +1,9 @@ -// +build linux freebsd solaris openbsd darwin +// +build linux freebsd openbsd darwin -package client +package client // import "github.com/docker/docker/client" // DefaultDockerHost defines os specific default if DOCKER_HOST is unset const DefaultDockerHost = "unix:///var/run/docker.sock" + +const defaultProto = "unix" +const defaultAddr = "/var/run/docker.sock" diff --git a/vendor/github.com/docker/docker/client/client_windows.go b/vendor/github.com/docker/docker/client/client_windows.go index 07c0c7a774..c649e54412 100644 --- a/vendor/github.com/docker/docker/client/client_windows.go +++ b/vendor/github.com/docker/docker/client/client_windows.go @@ -1,4 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" // DefaultDockerHost defines os specific default if DOCKER_HOST is unset const DefaultDockerHost = "npipe:////./pipe/docker_engine" + +const defaultProto = "npipe" +const defaultAddr = "//./pipe/docker_engine" diff --git a/vendor/github.com/docker/docker/client/config_create.go b/vendor/github.com/docker/docker/client/config_create.go index bc4a952b2f..c8b802ad35 100644 --- a/vendor/github.com/docker/docker/client/config_create.go +++ b/vendor/github.com/docker/docker/client/config_create.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // ConfigCreate creates a new Config. diff --git a/vendor/github.com/docker/docker/client/config_inspect.go b/vendor/github.com/docker/docker/client/config_inspect.go index b44d6fdd7e..4ac566ad89 100644 --- a/vendor/github.com/docker/docker/client/config_inspect.go +++ b/vendor/github.com/docker/docker/client/config_inspect.go @@ -1,16 +1,19 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // ConfigInspectWithRaw returns the config information with raw data func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { + if id == "" { + return swarm.Config{}, nil, objectNotFoundError{object: "config", id: id} + } if err := cli.NewVersionError("1.30", "config inspect"); err != nil { return swarm.Config{}, nil, err } diff --git a/vendor/github.com/docker/docker/client/config_list.go b/vendor/github.com/docker/docker/client/config_list.go index 57febc9ffb..2b9d54606b 100644 --- a/vendor/github.com/docker/docker/client/config_list.go +++ b/vendor/github.com/docker/docker/client/config_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // ConfigList returns the list of configs. diff --git a/vendor/github.com/docker/docker/client/config_remove.go b/vendor/github.com/docker/docker/client/config_remove.go index e025d44f79..a96871e98b 100644 --- a/vendor/github.com/docker/docker/client/config_remove.go +++ b/vendor/github.com/docker/docker/client/config_remove.go @@ -1,6 +1,6 @@ -package client +package client // import "github.com/docker/docker/client" -import "golang.org/x/net/context" +import "context" // ConfigRemove removes a Config. func (cli *Client) ConfigRemove(ctx context.Context, id string) error { diff --git a/vendor/github.com/docker/docker/client/config_update.go b/vendor/github.com/docker/docker/client/config_update.go index 823751bb86..39e59cf858 100644 --- a/vendor/github.com/docker/docker/client/config_update.go +++ b/vendor/github.com/docker/docker/client/config_update.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "strconv" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // ConfigUpdate attempts to update a Config diff --git a/vendor/github.com/docker/docker/client/container_attach.go b/vendor/github.com/docker/docker/client/container_attach.go index 0fdf3ed0ce..88ba1ef639 100644 --- a/vendor/github.com/docker/docker/client/container_attach.go +++ b/vendor/github.com/docker/docker/client/container_attach.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerAttach attaches a connection to a container in the server. diff --git a/vendor/github.com/docker/docker/client/container_commit.go b/vendor/github.com/docker/docker/client/container_commit.go index b3b16abfd1..377a2ea681 100644 --- a/vendor/github.com/docker/docker/client/container_commit.go +++ b/vendor/github.com/docker/docker/client/container_commit.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "errors" "net/url" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerCommit applies changes into a container and creates a new tagged image. diff --git a/vendor/github.com/docker/docker/client/container_copy.go b/vendor/github.com/docker/docker/client/container_copy.go index 30ba6803f0..d706260cee 100644 --- a/vendor/github.com/docker/docker/client/container_copy.go +++ b/vendor/github.com/docker/docker/client/container_copy.go @@ -1,6 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/base64" "encoding/json" "fmt" @@ -10,8 +11,6 @@ import ( "path/filepath" "strings" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" ) @@ -23,17 +22,17 @@ func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path stri urlStr := "/containers/" + containerID + "/archive" response, err := cli.head(ctx, urlStr, query, nil) if err != nil { - return types.ContainerPathStat{}, err + return types.ContainerPathStat{}, wrapResponseError(err, response, "container:path", containerID+":"+path) } defer ensureReaderClosed(response) return getContainerPathStatFromHeader(response.header) } // CopyToContainer copies content into the container filesystem. -// Note that `content` must be a Reader for a TAR -func (cli *Client) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error { +// Note that `content` must be a Reader for a TAR archive +func (cli *Client) CopyToContainer(ctx context.Context, containerID, dstPath string, content io.Reader, options types.CopyToContainerOptions) error { query := url.Values{} - query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API. + query.Set("path", filepath.ToSlash(dstPath)) // Normalize the paths used in the API. // Do not allow for an existing directory to be overwritten by a non-directory and vice versa. if !options.AllowOverwriteDirWithFile { query.Set("noOverwriteDirNonDir", "true") @@ -43,11 +42,11 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string, query.Set("copyUIDGID", "true") } - apiPath := "/containers/" + container + "/archive" + apiPath := "/containers/" + containerID + "/archive" response, err := cli.putRaw(ctx, apiPath, query, content, nil) if err != nil { - return err + return wrapResponseError(err, response, "container:path", containerID+":"+dstPath) } defer ensureReaderClosed(response) @@ -59,15 +58,15 @@ func (cli *Client) CopyToContainer(ctx context.Context, container, path string, } // CopyFromContainer gets the content from the container and returns it as a Reader -// to manipulate it in the host. It's up to the caller to close the reader. -func (cli *Client) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { +// for a TAR archive to manipulate it in the host. It's up to the caller to close the reader. +func (cli *Client) CopyFromContainer(ctx context.Context, containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { query := make(url.Values, 1) query.Set("path", filepath.ToSlash(srcPath)) // Normalize the paths used in the API. - apiPath := "/containers/" + container + "/archive" + apiPath := "/containers/" + containerID + "/archive" response, err := cli.get(ctx, apiPath, query, nil) if err != nil { - return nil, types.ContainerPathStat{}, err + return nil, types.ContainerPathStat{}, wrapResponseError(err, response, "container:path", containerID+":"+srcPath) } if response.statusCode != http.StatusOK { diff --git a/vendor/github.com/docker/docker/client/container_create.go b/vendor/github.com/docker/docker/client/container_create.go index bd817e7fd1..d269a61894 100644 --- a/vendor/github.com/docker/docker/client/container_create.go +++ b/vendor/github.com/docker/docker/client/container_create.go @@ -1,6 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "strings" @@ -8,7 +9,6 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/versions" - "golang.org/x/net/context" ) type configWrapper struct { diff --git a/vendor/github.com/docker/docker/client/container_diff.go b/vendor/github.com/docker/docker/client/container_diff.go index 884dc9feef..3b7c90c96c 100644 --- a/vendor/github.com/docker/docker/client/container_diff.go +++ b/vendor/github.com/docker/docker/client/container_diff.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/container" - "golang.org/x/net/context" ) // ContainerDiff shows differences in a container filesystem since it was started. diff --git a/vendor/github.com/docker/docker/client/container_exec.go b/vendor/github.com/docker/docker/client/container_exec.go index 29670d02e6..535536b1e0 100644 --- a/vendor/github.com/docker/docker/client/container_exec.go +++ b/vendor/github.com/docker/docker/client/container_exec.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerExecCreate creates a new exec configuration to run an exec process. diff --git a/vendor/github.com/docker/docker/client/container_export.go b/vendor/github.com/docker/docker/client/container_export.go index 52194f3d34..d0c0a5cbad 100644 --- a/vendor/github.com/docker/docker/client/container_export.go +++ b/vendor/github.com/docker/docker/client/container_export.go @@ -1,10 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" - - "golang.org/x/net/context" ) // ContainerExport retrieves the raw contents of a container diff --git a/vendor/github.com/docker/docker/client/container_inspect.go b/vendor/github.com/docker/docker/client/container_inspect.go index a15db14be8..e34bb16a26 100644 --- a/vendor/github.com/docker/docker/client/container_inspect.go +++ b/vendor/github.com/docker/docker/client/container_inspect.go @@ -1,30 +1,36 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerInspect returns the container information. func (cli *Client) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { + if containerID == "" { + return types.ContainerJSON{}, objectNotFoundError{object: "container", id: containerID} + } serverResp, err := cli.get(ctx, "/containers/"+containerID+"/json", nil, nil) if err != nil { return types.ContainerJSON{}, wrapResponseError(err, serverResp, "container", containerID) } + defer ensureReaderClosed(serverResp) var response types.ContainerJSON err = json.NewDecoder(serverResp.body).Decode(&response) - ensureReaderClosed(serverResp) return response, err } // ContainerInspectWithRaw returns the container information and its raw representation. func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID string, getSize bool) (types.ContainerJSON, []byte, error) { + if containerID == "" { + return types.ContainerJSON{}, nil, objectNotFoundError{object: "container", id: containerID} + } query := url.Values{} if getSize { query.Set("size", "1") diff --git a/vendor/github.com/docker/docker/client/container_kill.go b/vendor/github.com/docker/docker/client/container_kill.go index 29f80c73ad..4d6f1d23da 100644 --- a/vendor/github.com/docker/docker/client/container_kill.go +++ b/vendor/github.com/docker/docker/client/container_kill.go @@ -1,9 +1,8 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" - - "golang.org/x/net/context" ) // ContainerKill terminates the container process but does not remove the container from the docker host. diff --git a/vendor/github.com/docker/docker/client/container_list.go b/vendor/github.com/docker/docker/client/container_list.go index 4398912197..9c218e2218 100644 --- a/vendor/github.com/docker/docker/client/container_list.go +++ b/vendor/github.com/docker/docker/client/container_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "strconv" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // ContainerList returns the list of containers in the docker host. diff --git a/vendor/github.com/docker/docker/client/container_logs.go b/vendor/github.com/docker/docker/client/container_logs.go index 0f32e9f12b..5b6541f035 100644 --- a/vendor/github.com/docker/docker/client/container_logs.go +++ b/vendor/github.com/docker/docker/client/container_logs.go @@ -1,14 +1,14 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" "time" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" timetypes "github.com/docker/docker/api/types/time" + "github.com/pkg/errors" ) // ContainerLogs returns the logs generated by a container in an io.ReadCloser. @@ -46,11 +46,19 @@ func (cli *Client) ContainerLogs(ctx context.Context, container string, options if options.Since != "" { ts, err := timetypes.GetTimestamp(options.Since, time.Now()) if err != nil { - return nil, err + return nil, errors.Wrap(err, `invalid value for "since"`) } query.Set("since", ts) } + if options.Until != "" { + ts, err := timetypes.GetTimestamp(options.Until, time.Now()) + if err != nil { + return nil, errors.Wrap(err, `invalid value for "until"`) + } + query.Set("until", ts) + } + if options.Timestamps { query.Set("timestamps", "1") } @@ -66,7 +74,7 @@ func (cli *Client) ContainerLogs(ctx context.Context, container string, options resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil) if err != nil { - return nil, err + return nil, wrapResponseError(err, resp, "container", container) } return resp.body, nil } diff --git a/vendor/github.com/docker/docker/client/container_pause.go b/vendor/github.com/docker/docker/client/container_pause.go index 412067a782..5e7271a371 100644 --- a/vendor/github.com/docker/docker/client/container_pause.go +++ b/vendor/github.com/docker/docker/client/container_pause.go @@ -1,6 +1,6 @@ -package client +package client // import "github.com/docker/docker/client" -import "golang.org/x/net/context" +import "context" // ContainerPause pauses the main process of a given container without terminating it. func (cli *Client) ContainerPause(ctx context.Context, containerID string) error { diff --git a/vendor/github.com/docker/docker/client/container_prune.go b/vendor/github.com/docker/docker/client/container_prune.go index b582170867..14f88d93ba 100644 --- a/vendor/github.com/docker/docker/client/container_prune.go +++ b/vendor/github.com/docker/docker/client/container_prune.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // ContainersPrune requests the daemon to delete unused data diff --git a/vendor/github.com/docker/docker/client/container_remove.go b/vendor/github.com/docker/docker/client/container_remove.go index 070108bf3e..ab4cfc16f8 100644 --- a/vendor/github.com/docker/docker/client/container_remove.go +++ b/vendor/github.com/docker/docker/client/container_remove.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerRemove kills and removes a container from the docker host. diff --git a/vendor/github.com/docker/docker/client/container_rename.go b/vendor/github.com/docker/docker/client/container_rename.go index 0e718da7c6..240fdf552b 100644 --- a/vendor/github.com/docker/docker/client/container_rename.go +++ b/vendor/github.com/docker/docker/client/container_rename.go @@ -1,9 +1,8 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" - - "golang.org/x/net/context" ) // ContainerRename changes the name of a given container. diff --git a/vendor/github.com/docker/docker/client/container_resize.go b/vendor/github.com/docker/docker/client/container_resize.go index 66c3cc1940..a9d4c0c79a 100644 --- a/vendor/github.com/docker/docker/client/container_resize.go +++ b/vendor/github.com/docker/docker/client/container_resize.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "strconv" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerResize changes the size of the tty for a container. diff --git a/vendor/github.com/docker/docker/client/container_restart.go b/vendor/github.com/docker/docker/client/container_restart.go index 74d7455f02..41e421969f 100644 --- a/vendor/github.com/docker/docker/client/container_restart.go +++ b/vendor/github.com/docker/docker/client/container_restart.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "time" timetypes "github.com/docker/docker/api/types/time" - "golang.org/x/net/context" ) // ContainerRestart stops and starts a container again. diff --git a/vendor/github.com/docker/docker/client/container_start.go b/vendor/github.com/docker/docker/client/container_start.go index b1f08de416..c2e0b15dca 100644 --- a/vendor/github.com/docker/docker/client/container_start.go +++ b/vendor/github.com/docker/docker/client/container_start.go @@ -1,10 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" ) diff --git a/vendor/github.com/docker/docker/client/container_stats.go b/vendor/github.com/docker/docker/client/container_stats.go index 4758c66e32..6ef44c7748 100644 --- a/vendor/github.com/docker/docker/client/container_stats.go +++ b/vendor/github.com/docker/docker/client/container_stats.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ContainerStats returns near realtime stats for a given container. diff --git a/vendor/github.com/docker/docker/client/container_stop.go b/vendor/github.com/docker/docker/client/container_stop.go index b5418ae8c8..629d7ab64c 100644 --- a/vendor/github.com/docker/docker/client/container_stop.go +++ b/vendor/github.com/docker/docker/client/container_stop.go @@ -1,15 +1,20 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "time" timetypes "github.com/docker/docker/api/types/time" - "golang.org/x/net/context" ) -// ContainerStop stops a container without terminating the process. -// The process is blocked until the container stops or the timeout expires. +// ContainerStop stops a container. In case the container fails to stop +// gracefully within a time frame specified by the timeout argument, +// it is forcefully terminated (killed). +// +// If the timeout is nil, the container's StopTimeout value is used, if set, +// otherwise the engine default. A negative timeout value can be specified, +// meaning no timeout, i.e. no forceful termination is performed. func (cli *Client) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error { query := url.Values{} if timeout != nil { diff --git a/vendor/github.com/docker/docker/client/container_top.go b/vendor/github.com/docker/docker/client/container_top.go index 9689123a40..9c9fce7a04 100644 --- a/vendor/github.com/docker/docker/client/container_top.go +++ b/vendor/github.com/docker/docker/client/container_top.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "strings" "github.com/docker/docker/api/types/container" - "golang.org/x/net/context" ) // ContainerTop shows process information from within a container. diff --git a/vendor/github.com/docker/docker/client/container_unpause.go b/vendor/github.com/docker/docker/client/container_unpause.go index 5c76211256..1d8f873169 100644 --- a/vendor/github.com/docker/docker/client/container_unpause.go +++ b/vendor/github.com/docker/docker/client/container_unpause.go @@ -1,6 +1,6 @@ -package client +package client // import "github.com/docker/docker/client" -import "golang.org/x/net/context" +import "context" // ContainerUnpause resumes the process execution within a container func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error { diff --git a/vendor/github.com/docker/docker/client/container_update.go b/vendor/github.com/docker/docker/client/container_update.go index 5082f22dfa..14e7f23dfb 100644 --- a/vendor/github.com/docker/docker/client/container_update.go +++ b/vendor/github.com/docker/docker/client/container_update.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types/container" - "golang.org/x/net/context" ) // ContainerUpdate updates resources of a container diff --git a/vendor/github.com/docker/docker/client/container_wait.go b/vendor/github.com/docker/docker/client/container_wait.go index 854c6c053b..6ab8c1da96 100644 --- a/vendor/github.com/docker/docker/client/container_wait.go +++ b/vendor/github.com/docker/docker/client/container_wait.go @@ -1,11 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" - "golang.org/x/net/context" - "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/versions" ) diff --git a/vendor/github.com/docker/docker/client/disk_usage.go b/vendor/github.com/docker/docker/client/disk_usage.go index 03c80b39af..8eb30eb5de 100644 --- a/vendor/github.com/docker/docker/client/disk_usage.go +++ b/vendor/github.com/docker/docker/client/disk_usage.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // DiskUsage requests the current data usage from the daemon diff --git a/vendor/github.com/docker/docker/client/distribution_inspect.go b/vendor/github.com/docker/docker/client/distribution_inspect.go index aa5bc6a6c6..7245bbeeda 100644 --- a/vendor/github.com/docker/docker/client/distribution_inspect.go +++ b/vendor/github.com/docker/docker/client/distribution_inspect.go @@ -1,17 +1,20 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" registrytypes "github.com/docker/docker/api/types/registry" - "golang.org/x/net/context" ) // DistributionInspect returns the image digest with full Manifest func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registrytypes.DistributionInspect, error) { // Contact the registry to retrieve digest and platform information var distributionInspect registrytypes.DistributionInspect + if image == "" { + return distributionInspect, objectNotFoundError{object: "distribution", id: image} + } if err := cli.NewVersionError("1.30", "distribution inspect"); err != nil { return distributionInspect, err diff --git a/vendor/github.com/docker/docker/client/errors.go b/vendor/github.com/docker/docker/client/errors.go index e41b728d3a..0461af329d 100644 --- a/vendor/github.com/docker/docker/client/errors.go +++ b/vendor/github.com/docker/docker/client/errors.go @@ -1,8 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( "fmt" - "net/http" "github.com/docker/docker/api/types/versions" diff --git a/vendor/github.com/docker/docker/client/events.go b/vendor/github.com/docker/docker/client/events.go index af47aefa74..6e56538955 100644 --- a/vendor/github.com/docker/docker/client/events.go +++ b/vendor/github.com/docker/docker/client/events.go @@ -1,12 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "time" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" diff --git a/vendor/github.com/docker/docker/client/hijack.go b/vendor/github.com/docker/docker/client/hijack.go index d04cebdcf4..0ac8248f2c 100644 --- a/vendor/github.com/docker/docker/client/hijack.go +++ b/vendor/github.com/docker/docker/client/hijack.go @@ -1,37 +1,21 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bufio" + "context" "crypto/tls" "fmt" "net" "net/http" "net/http/httputil" "net/url" - "strings" "time" "github.com/docker/docker/api/types" "github.com/docker/go-connections/sockets" "github.com/pkg/errors" - "golang.org/x/net/context" ) -// tlsClientCon holds tls information and a dialed connection. -type tlsClientCon struct { - *tls.Conn - rawConn net.Conn -} - -func (c *tlsClientCon) CloseWrite() error { - // Go standard tls.Conn doesn't provide the CloseWrite() method so we do it - // on its underlying connection. - if conn, ok := c.rawConn.(types.CloseWriter); ok { - return conn.CloseWrite() - } - return nil -} - // postHijacked sends a POST request and hijacks the connection. func (cli *Client) postHijacked(ctx context.Context, path string, query url.Values, body interface{}, headers map[string][]string) (types.HijackedResponse, error) { bodyEncoded, err := encodeData(body) @@ -46,7 +30,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu } req = cli.addHeaders(req, headers) - conn, err := cli.setupHijackConn(req, "tcp") + conn, err := cli.setupHijackConn(ctx, req, "tcp") if err != nil { return types.HijackedResponse{}, err } @@ -54,96 +38,11 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu return types.HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn)}, err } -func tlsDial(network, addr string, config *tls.Config) (net.Conn, error) { - return tlsDialWithDialer(new(net.Dialer), network, addr, config) -} - -// We need to copy Go's implementation of tls.Dial (pkg/cryptor/tls/tls.go) in -// order to return our custom tlsClientCon struct which holds both the tls.Conn -// object _and_ its underlying raw connection. The rationale for this is that -// we need to be able to close the write end of the connection when attaching, -// which tls.Conn does not provide. -func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) { - // We want the Timeout and Deadline values from dialer to cover the - // whole process: TCP connection and TLS handshake. This means that we - // also need to start our own timers now. - timeout := dialer.Timeout - - if !dialer.Deadline.IsZero() { - deadlineTimeout := time.Until(dialer.Deadline) - if timeout == 0 || deadlineTimeout < timeout { - timeout = deadlineTimeout - } - } - - var errChannel chan error - - if timeout != 0 { - errChannel = make(chan error, 2) - time.AfterFunc(timeout, func() { - errChannel <- errors.New("") - }) - } - - proxyDialer, err := sockets.DialerFromEnvironment(dialer) - if err != nil { - return nil, err - } - - rawConn, err := proxyDialer.Dial(network, addr) - if err != nil { - return nil, err - } - // When we set up a TCP connection for hijack, there could be long periods - // of inactivity (a long running command with no output) that in certain - // network setups may cause ECONNTIMEOUT, leaving the client in an unknown - // state. Setting TCP KeepAlive on the socket connection will prohibit - // ECONNTIMEOUT unless the socket connection truly is broken - if tcpConn, ok := rawConn.(*net.TCPConn); ok { - tcpConn.SetKeepAlive(true) - tcpConn.SetKeepAlivePeriod(30 * time.Second) - } - - colonPos := strings.LastIndex(addr, ":") - if colonPos == -1 { - colonPos = len(addr) - } - hostname := addr[:colonPos] - - // If no ServerName is set, infer the ServerName - // from the hostname we're connecting to. - if config.ServerName == "" { - // Make a copy to avoid polluting argument or default. - config = tlsConfigClone(config) - config.ServerName = hostname - } - - conn := tls.Client(rawConn, config) - - if timeout == 0 { - err = conn.Handshake() - } else { - go func() { - errChannel <- conn.Handshake() - }() - - err = <-errChannel - } - - if err != nil { - rawConn.Close() - return nil, err - } - - // This is Docker difference with standard's crypto/tls package: returned a - // wrapper which holds both the TLS and raw connections. - return &tlsClientCon{conn, rawConn}, nil -} - -func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { +// fallbackDial is used when WithDialer() was not called. +// See cli.Dialer(). +func fallbackDial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { if tlsConfig != nil && proto != "unix" && proto != "npipe" { - // Notice this isn't Go standard's tls.Dial function - return tlsDial(proto, addr, tlsConfig) + return tls.Dial(proto, addr, tlsConfig) } if proto == "npipe" { return sockets.DialPipe(addr, 32*time.Second) @@ -151,12 +50,13 @@ func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { return net.Dial(proto, addr) } -func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, error) { +func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto string) (net.Conn, error) { req.Host = cli.addr req.Header.Set("Connection", "Upgrade") req.Header.Set("Upgrade", proto) - conn, err := dial(cli.proto, cli.addr, resolveTLSConfig(cli.client.Transport)) + dialer := cli.Dialer() + conn, err := dialer(ctx) if err != nil { return nil, errors.Wrap(err, "cannot connect to the Docker daemon. Is 'docker daemon' running on this host?") } @@ -188,8 +88,14 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, e c, br := clientconn.Hijack() if br.Buffered() > 0 { - // If there is buffered content, wrap the connection - c = &hijackedConn{c, br} + // If there is buffered content, wrap the connection. We return an + // object that implements CloseWrite iff the underlying connection + // implements it. + if _, ok := c.(types.CloseWriter); ok { + c = &hijackedConnCloseWriter{&hijackedConn{c, br}} + } else { + c = &hijackedConn{c, br} + } } else { br.Reset(nil) } @@ -197,6 +103,10 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, e return c, nil } +// hijackedConn wraps a net.Conn and is returned by setupHijackConn in the case +// that a) there was already buffered data in the http layer when Hijack() was +// called, and b) the underlying net.Conn does *not* implement CloseWrite(). +// hijackedConn does not implement CloseWrite() either. type hijackedConn struct { net.Conn r *bufio.Reader @@ -205,3 +115,18 @@ type hijackedConn struct { func (c *hijackedConn) Read(b []byte) (int, error) { return c.r.Read(b) } + +// hijackedConnCloseWriter is a hijackedConn which additionally implements +// CloseWrite(). It is returned by setupHijackConn in the case that a) there +// was already buffered data in the http layer when Hijack() was called, and b) +// the underlying net.Conn *does* implement CloseWrite(). +type hijackedConnCloseWriter struct { + *hijackedConn +} + +var _ types.CloseWriter = &hijackedConnCloseWriter{} + +func (c *hijackedConnCloseWriter) CloseWrite() error { + conn := c.Conn.(types.CloseWriter) + return conn.CloseWrite() +} diff --git a/vendor/github.com/docker/docker/client/image_build.go b/vendor/github.com/docker/docker/client/image_build.go index cd0f54d138..9add3c10b3 100644 --- a/vendor/github.com/docker/docker/client/image_build.go +++ b/vendor/github.com/docker/docker/client/image_build.go @@ -1,6 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/base64" "encoding/json" "io" @@ -9,8 +10,6 @@ import ( "strconv" "strings" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" ) @@ -31,12 +30,6 @@ func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, optio } headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) - if options.Platform != "" { - if err := cli.NewVersionError("1.32", "platform"); err != nil { - return types.ImageBuildResponse{}, err - } - query.Set("platform", options.Platform) - } headers.Set("Content-Type", "application/x-tar") serverResp, err := cli.postRaw(ctx, "/build", query, buildContext, headers) @@ -132,7 +125,14 @@ func (cli *Client) imageBuildOptionsToQuery(options types.ImageBuildOptions) (ur query.Set("session", options.SessionID) } if options.Platform != "" { + if err := cli.NewVersionError("1.32", "platform"); err != nil { + return query, err + } query.Set("platform", strings.ToLower(options.Platform)) } + if options.BuildID != "" { + query.Set("buildid", options.BuildID) + } + query.Set("version", string(options.Version)) return query, nil } diff --git a/vendor/github.com/docker/docker/client/image_create.go b/vendor/github.com/docker/docker/client/image_create.go index fb5447b9b6..239380474e 100644 --- a/vendor/github.com/docker/docker/client/image_create.go +++ b/vendor/github.com/docker/docker/client/image_create.go @@ -1,12 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" "strings" - "golang.org/x/net/context" - "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" ) diff --git a/vendor/github.com/docker/docker/client/image_history.go b/vendor/github.com/docker/docker/client/image_history.go index 7b4babcba3..0151b9517f 100644 --- a/vendor/github.com/docker/docker/client/image_history.go +++ b/vendor/github.com/docker/docker/client/image_history.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/image" - "golang.org/x/net/context" ) // ImageHistory returns the changes in an image in history format. diff --git a/vendor/github.com/docker/docker/client/image_import.go b/vendor/github.com/docker/docker/client/image_import.go index ab55ddbacb..c2972ea950 100644 --- a/vendor/github.com/docker/docker/client/image_import.go +++ b/vendor/github.com/docker/docker/client/image_import.go @@ -1,12 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" "strings" - "golang.org/x/net/context" - "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" ) diff --git a/vendor/github.com/docker/docker/client/image_inspect.go b/vendor/github.com/docker/docker/client/image_inspect.go index 1bc5919907..2f8f6d2f14 100644 --- a/vendor/github.com/docker/docker/client/image_inspect.go +++ b/vendor/github.com/docker/docker/client/image_inspect.go @@ -1,16 +1,19 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ImageInspectWithRaw returns the image information and its raw representation. func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { + if imageID == "" { + return types.ImageInspect{}, nil, objectNotFoundError{object: "image", id: imageID} + } serverResp, err := cli.get(ctx, "/images/"+imageID+"/json", nil, nil) if err != nil { return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID) diff --git a/vendor/github.com/docker/docker/client/image_list.go b/vendor/github.com/docker/docker/client/image_list.go index f26464f67c..32fae27b37 100644 --- a/vendor/github.com/docker/docker/client/image_list.go +++ b/vendor/github.com/docker/docker/client/image_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/versions" - "golang.org/x/net/context" ) // ImageList returns a list of images in the docker host. diff --git a/vendor/github.com/docker/docker/client/image_load.go b/vendor/github.com/docker/docker/client/image_load.go index 77aaf1af36..91016e493c 100644 --- a/vendor/github.com/docker/docker/client/image_load.go +++ b/vendor/github.com/docker/docker/client/image_load.go @@ -1,11 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" ) diff --git a/vendor/github.com/docker/docker/client/image_prune.go b/vendor/github.com/docker/docker/client/image_prune.go index 5ef98b7f02..78ee3f6c49 100644 --- a/vendor/github.com/docker/docker/client/image_prune.go +++ b/vendor/github.com/docker/docker/client/image_prune.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // ImagesPrune requests the daemon to delete unused data diff --git a/vendor/github.com/docker/docker/client/image_pull.go b/vendor/github.com/docker/docker/client/image_pull.go index 92942d2e5b..d97aacf8c5 100644 --- a/vendor/github.com/docker/docker/client/image_pull.go +++ b/vendor/github.com/docker/docker/client/image_pull.go @@ -1,13 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/http" "net/url" "strings" - "golang.org/x/net/context" - "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" ) diff --git a/vendor/github.com/docker/docker/client/image_push.go b/vendor/github.com/docker/docker/client/image_push.go index 410d2fb91d..a15871c2b4 100644 --- a/vendor/github.com/docker/docker/client/image_push.go +++ b/vendor/github.com/docker/docker/client/image_push.go @@ -1,13 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "errors" "io" "net/http" "net/url" - "golang.org/x/net/context" - "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" ) diff --git a/vendor/github.com/docker/docker/client/image_remove.go b/vendor/github.com/docker/docker/client/image_remove.go index 81d6c5438d..45d6e6f0db 100644 --- a/vendor/github.com/docker/docker/client/image_remove.go +++ b/vendor/github.com/docker/docker/client/image_remove.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ImageRemove removes an image from the docker host. diff --git a/vendor/github.com/docker/docker/client/image_save.go b/vendor/github.com/docker/docker/client/image_save.go index ecac880a32..d1314e4b22 100644 --- a/vendor/github.com/docker/docker/client/image_save.go +++ b/vendor/github.com/docker/docker/client/image_save.go @@ -1,10 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" - - "golang.org/x/net/context" ) // ImageSave retrieves one or more images from the docker host as an io.ReadCloser. diff --git a/vendor/github.com/docker/docker/client/image_search.go b/vendor/github.com/docker/docker/client/image_search.go index 5566e92555..176de3c582 100644 --- a/vendor/github.com/docker/docker/client/image_search.go +++ b/vendor/github.com/docker/docker/client/image_search.go @@ -1,6 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "net/http" @@ -9,7 +10,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/registry" - "golang.org/x/net/context" ) // ImageSearch makes the docker host to search by a term in a remote registry. diff --git a/vendor/github.com/docker/docker/client/image_tag.go b/vendor/github.com/docker/docker/client/image_tag.go index 8924f71eb3..5652bfc252 100644 --- a/vendor/github.com/docker/docker/client/image_tag.go +++ b/vendor/github.com/docker/docker/client/image_tag.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/distribution/reference" "github.com/pkg/errors" - "golang.org/x/net/context" ) // ImageTag tags an image in the docker host diff --git a/vendor/github.com/docker/docker/client/info.go b/vendor/github.com/docker/docker/client/info.go index ac07961224..121f256ab1 100644 --- a/vendor/github.com/docker/docker/client/info.go +++ b/vendor/github.com/docker/docker/client/info.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // Info returns information about the docker server. diff --git a/vendor/github.com/docker/docker/client/interface.go b/vendor/github.com/docker/docker/client/interface.go index dd8b388cfa..d190f8e58d 100644 --- a/vendor/github.com/docker/docker/client/interface.go +++ b/vendor/github.com/docker/docker/client/interface.go @@ -1,20 +1,21 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net" + "net/http" "time" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" + containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" + networktypes "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" volumetypes "github.com/docker/docker/api/types/volume" - "golang.org/x/net/context" ) // CommonAPIClient is the common methods between stable and experimental versions of APIClient. @@ -33,18 +34,21 @@ type CommonAPIClient interface { VolumeAPIClient ClientVersion() string DaemonHost() string + HTTPClient() *http.Client ServerVersion(ctx context.Context) (types.Version, error) NegotiateAPIVersion(ctx context.Context) NegotiateAPIVersionPing(types.Ping) DialSession(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) + Dialer() func(context.Context) (net.Conn, error) + Close() error } // ContainerAPIClient defines API client methods for the containers type ContainerAPIClient interface { ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) - ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) - ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error) + ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, containerName string) (containertypes.ContainerCreateCreatedBody, error) + ContainerDiff(ctx context.Context, container string) ([]containertypes.ContainerChangeResponseItem, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) @@ -65,10 +69,10 @@ type ContainerAPIClient interface { ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error) ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error ContainerStop(ctx context.Context, container string, timeout *time.Duration) error - ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error) + ContainerTop(ctx context.Context, container string, arguments []string) (containertypes.ContainerTopOKBody, error) ContainerUnpause(ctx context.Context, container string) error - ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) - ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) + ContainerUpdate(ctx context.Context, container string, updateConfig containertypes.UpdateConfig) (containertypes.ContainerUpdateOKBody, error) + ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.ContainerWaitOKBody, <-chan error) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) @@ -82,7 +86,8 @@ type DistributionAPIClient interface { // ImageAPIClient defines API client methods for the images type ImageAPIClient interface { ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) - BuildCachePrune(ctx context.Context) (*types.BuildCachePruneReport, error) + BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) + BuildCancel(ctx context.Context, id string) error ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) @@ -100,13 +105,13 @@ type ImageAPIClient interface { // NetworkAPIClient defines API client methods for the networks type NetworkAPIClient interface { - NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error + NetworkConnect(ctx context.Context, network, container string, config *networktypes.EndpointSettings) error NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) - NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error - NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) - NetworkInspectWithRaw(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) + NetworkDisconnect(ctx context.Context, network, container string, force bool) error + NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error) + NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) - NetworkRemove(ctx context.Context, networkID string) error + NetworkRemove(ctx context.Context, network string) error NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) } @@ -167,10 +172,10 @@ type SystemAPIClient interface { // VolumeAPIClient defines API client methods for the volumes type VolumeAPIClient interface { - VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) + VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) - VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) + VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) VolumeRemove(ctx context.Context, volumeID string, force bool) error VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error) } diff --git a/vendor/github.com/docker/docker/client/interface_experimental.go b/vendor/github.com/docker/docker/client/interface_experimental.go index 51da98ecdd..402ffb512c 100644 --- a/vendor/github.com/docker/docker/client/interface_experimental.go +++ b/vendor/github.com/docker/docker/client/interface_experimental.go @@ -1,8 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) type apiClientExperimental interface { diff --git a/vendor/github.com/docker/docker/client/interface_stable.go b/vendor/github.com/docker/docker/client/interface_stable.go index cc90a3cbb9..5502cd7426 100644 --- a/vendor/github.com/docker/docker/client/interface_stable.go +++ b/vendor/github.com/docker/docker/client/interface_stable.go @@ -1,4 +1,4 @@ -package client +package client // import "github.com/docker/docker/client" // APIClient is an interface that clients that talk with a docker server must implement. type APIClient interface { diff --git a/vendor/github.com/docker/docker/client/login.go b/vendor/github.com/docker/docker/client/login.go index 79219ff59c..7d66181900 100644 --- a/vendor/github.com/docker/docker/client/login.go +++ b/vendor/github.com/docker/docker/client/login.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/http" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" - "golang.org/x/net/context" ) // RegistryLogin authenticates the docker server with a given docker registry. diff --git a/vendor/github.com/docker/docker/client/network_connect.go b/vendor/github.com/docker/docker/client/network_connect.go index c022c17b5b..5718946134 100644 --- a/vendor/github.com/docker/docker/client/network_connect.go +++ b/vendor/github.com/docker/docker/client/network_connect.go @@ -1,9 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" - "golang.org/x/net/context" ) // NetworkConnect connects a container to an existent network in the docker host. diff --git a/vendor/github.com/docker/docker/client/network_create.go b/vendor/github.com/docker/docker/client/network_create.go index 4067a541ff..41da2ac610 100644 --- a/vendor/github.com/docker/docker/client/network_create.go +++ b/vendor/github.com/docker/docker/client/network_create.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // NetworkCreate creates a new network in the docker host. diff --git a/vendor/github.com/docker/docker/client/network_disconnect.go b/vendor/github.com/docker/docker/client/network_disconnect.go index 24b58e3c12..dd15676656 100644 --- a/vendor/github.com/docker/docker/client/network_disconnect.go +++ b/vendor/github.com/docker/docker/client/network_disconnect.go @@ -1,8 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // NetworkDisconnect disconnects a container from an existent network in the docker host. diff --git a/vendor/github.com/docker/docker/client/network_inspect.go b/vendor/github.com/docker/docker/client/network_inspect.go index afabe65970..025f6d8757 100644 --- a/vendor/github.com/docker/docker/client/network_inspect.go +++ b/vendor/github.com/docker/docker/client/network_inspect.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // NetworkInspect returns the information for a specific network configured in the docker host. @@ -18,6 +18,9 @@ func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation. func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { + if networkID == "" { + return types.NetworkResource{}, nil, objectNotFoundError{object: "network", id: networkID} + } var ( networkResource types.NetworkResource resp serverResponse diff --git a/vendor/github.com/docker/docker/client/network_list.go b/vendor/github.com/docker/docker/client/network_list.go index e566a93e23..f16b2f5624 100644 --- a/vendor/github.com/docker/docker/client/network_list.go +++ b/vendor/github.com/docker/docker/client/network_list.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // NetworkList returns the list of networks configured in the docker host. diff --git a/vendor/github.com/docker/docker/client/network_prune.go b/vendor/github.com/docker/docker/client/network_prune.go index 7352a7f0c5..6418b8b607 100644 --- a/vendor/github.com/docker/docker/client/network_prune.go +++ b/vendor/github.com/docker/docker/client/network_prune.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // NetworksPrune requests the daemon to delete unused networks diff --git a/vendor/github.com/docker/docker/client/network_remove.go b/vendor/github.com/docker/docker/client/network_remove.go index 0811b5b51c..12741437be 100644 --- a/vendor/github.com/docker/docker/client/network_remove.go +++ b/vendor/github.com/docker/docker/client/network_remove.go @@ -1,6 +1,6 @@ -package client +package client // import "github.com/docker/docker/client" -import "golang.org/x/net/context" +import "context" // NetworkRemove removes an existent network from the docker host. func (cli *Client) NetworkRemove(ctx context.Context, networkID string) error { diff --git a/vendor/github.com/docker/docker/client/node_inspect.go b/vendor/github.com/docker/docker/client/node_inspect.go index 791d2c0066..593b2e9f0b 100644 --- a/vendor/github.com/docker/docker/client/node_inspect.go +++ b/vendor/github.com/docker/docker/client/node_inspect.go @@ -1,16 +1,19 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // NodeInspectWithRaw returns the node information. func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) { + if nodeID == "" { + return swarm.Node{}, nil, objectNotFoundError{object: "node", id: nodeID} + } serverResp, err := cli.get(ctx, "/nodes/"+nodeID, nil, nil) if err != nil { return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID) diff --git a/vendor/github.com/docker/docker/client/node_list.go b/vendor/github.com/docker/docker/client/node_list.go index fed22992c9..9883f6fc52 100644 --- a/vendor/github.com/docker/docker/client/node_list.go +++ b/vendor/github.com/docker/docker/client/node_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // NodeList returns the list of nodes. diff --git a/vendor/github.com/docker/docker/client/node_remove.go b/vendor/github.com/docker/docker/client/node_remove.go index adbf52febb..e7a7505715 100644 --- a/vendor/github.com/docker/docker/client/node_remove.go +++ b/vendor/github.com/docker/docker/client/node_remove.go @@ -1,11 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - - "golang.org/x/net/context" ) // NodeRemove removes a Node. diff --git a/vendor/github.com/docker/docker/client/node_update.go b/vendor/github.com/docker/docker/client/node_update.go index 3ca9760282..de32a617fb 100644 --- a/vendor/github.com/docker/docker/client/node_update.go +++ b/vendor/github.com/docker/docker/client/node_update.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "strconv" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // NodeUpdate updates a Node. diff --git a/vendor/github.com/docker/docker/client/options.go b/vendor/github.com/docker/docker/client/options.go new file mode 100644 index 0000000000..12eb25b18e --- /dev/null +++ b/vendor/github.com/docker/docker/client/options.go @@ -0,0 +1,144 @@ +package client + +import ( + "context" + "net" + "net/http" + "os" + "path/filepath" + + "github.com/docker/go-connections/sockets" + "github.com/docker/go-connections/tlsconfig" + "github.com/pkg/errors" +) + +// FromEnv configures the client with values from environment variables. +// +// Supported environment variables: +// DOCKER_HOST to set the url to the docker server. +// DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest. +// DOCKER_CERT_PATH to load the TLS certificates from. +// DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default. +func FromEnv(c *Client) error { + if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" { + options := tlsconfig.Options{ + CAFile: filepath.Join(dockerCertPath, "ca.pem"), + CertFile: filepath.Join(dockerCertPath, "cert.pem"), + KeyFile: filepath.Join(dockerCertPath, "key.pem"), + InsecureSkipVerify: os.Getenv("DOCKER_TLS_VERIFY") == "", + } + tlsc, err := tlsconfig.Client(options) + if err != nil { + return err + } + + c.client = &http.Client{ + Transport: &http.Transport{TLSClientConfig: tlsc}, + CheckRedirect: CheckRedirect, + } + } + + if host := os.Getenv("DOCKER_HOST"); host != "" { + if err := WithHost(host)(c); err != nil { + return err + } + } + + if version := os.Getenv("DOCKER_API_VERSION"); version != "" { + c.version = version + c.manualOverride = true + } + return nil +} + +// WithDialer applies the dialer.DialContext to the client transport. This can be +// used to set the Timeout and KeepAlive settings of the client. +// Deprecated: use WithDialContext +func WithDialer(dialer *net.Dialer) func(*Client) error { + return WithDialContext(dialer.DialContext) +} + +// WithDialContext applies the dialer to the client transport. This can be +// used to set the Timeout and KeepAlive settings of the client. +func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) func(*Client) error { + return func(c *Client) error { + if transport, ok := c.client.Transport.(*http.Transport); ok { + transport.DialContext = dialContext + return nil + } + return errors.Errorf("cannot apply dialer to transport: %T", c.client.Transport) + } +} + +// WithHost overrides the client host with the specified one. +func WithHost(host string) func(*Client) error { + return func(c *Client) error { + hostURL, err := ParseHostURL(host) + if err != nil { + return err + } + c.host = host + c.proto = hostURL.Scheme + c.addr = hostURL.Host + c.basePath = hostURL.Path + if transport, ok := c.client.Transport.(*http.Transport); ok { + return sockets.ConfigureTransport(transport, c.proto, c.addr) + } + return errors.Errorf("cannot apply host to transport: %T", c.client.Transport) + } +} + +// WithHTTPClient overrides the client http client with the specified one +func WithHTTPClient(client *http.Client) func(*Client) error { + return func(c *Client) error { + if client != nil { + c.client = client + } + return nil + } +} + +// WithHTTPHeaders overrides the client default http headers +func WithHTTPHeaders(headers map[string]string) func(*Client) error { + return func(c *Client) error { + c.customHTTPHeaders = headers + return nil + } +} + +// WithScheme overrides the client scheme with the specified one +func WithScheme(scheme string) func(*Client) error { + return func(c *Client) error { + c.scheme = scheme + return nil + } +} + +// WithTLSClientConfig applies a tls config to the client transport. +func WithTLSClientConfig(cacertPath, certPath, keyPath string) func(*Client) error { + return func(c *Client) error { + opts := tlsconfig.Options{ + CAFile: cacertPath, + CertFile: certPath, + KeyFile: keyPath, + ExclusiveRootPools: true, + } + config, err := tlsconfig.Client(opts) + if err != nil { + return errors.Wrap(err, "failed to create tls config") + } + if transport, ok := c.client.Transport.(*http.Transport); ok { + transport.TLSClientConfig = config + return nil + } + return errors.Errorf("cannot apply tls config to transport: %T", c.client.Transport) + } +} + +// WithVersion overrides the client version with the specified one +func WithVersion(version string) func(*Client) error { + return func(c *Client) error { + c.version = version + return nil + } +} diff --git a/vendor/github.com/docker/docker/client/ping.go b/vendor/github.com/docker/docker/client/ping.go index 0b6e450da7..0ebb6b752b 100644 --- a/vendor/github.com/docker/docker/client/ping.go +++ b/vendor/github.com/docker/docker/client/ping.go @@ -1,32 +1,57 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "net/http" "path" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) -// Ping pings the server and returns the value of the "Docker-Experimental", "OS-Type" & "API-Version" headers +// Ping pings the server and returns the value of the "Docker-Experimental", +// "Builder-Version", "OS-Type" & "API-Version" headers. It attempts to use +// a HEAD request on the endpoint, but falls back to GET if HEAD is not supported +// by the daemon. func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { var ping types.Ping - req, err := cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil) + req, err := cli.buildRequest("HEAD", path.Join(cli.basePath, "/_ping"), nil, nil) if err != nil { return ping, err } serverResp, err := cli.doRequest(ctx, req) + if err == nil { + defer ensureReaderClosed(serverResp) + switch serverResp.statusCode { + case http.StatusOK, http.StatusInternalServerError: + // Server handled the request, so parse the response + return parsePingResponse(cli, serverResp) + } + } + + req, err = cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil) + if err != nil { + return ping, err + } + serverResp, err = cli.doRequest(ctx, req) if err != nil { return ping, err } defer ensureReaderClosed(serverResp) + return parsePingResponse(cli, serverResp) +} - if serverResp.header != nil { - ping.APIVersion = serverResp.header.Get("API-Version") - - if serverResp.header.Get("Docker-Experimental") == "true" { - ping.Experimental = true - } - ping.OSType = serverResp.header.Get("OSType") +func parsePingResponse(cli *Client, resp serverResponse) (types.Ping, error) { + var ping types.Ping + if resp.header == nil { + return ping, cli.checkResponseErr(resp) + } + ping.APIVersion = resp.header.Get("API-Version") + ping.OSType = resp.header.Get("OSType") + if resp.header.Get("Docker-Experimental") == "true" { + ping.Experimental = true + } + if bv := resp.header.Get("Builder-Version"); bv != "" { + ping.BuilderVersion = types.BuilderVersion(bv) } - return ping, cli.checkResponseErr(serverResp) + return ping, cli.checkResponseErr(resp) } diff --git a/vendor/github.com/docker/docker/client/plugin_create.go b/vendor/github.com/docker/docker/client/plugin_create.go index 27954aa573..4591db50fd 100644 --- a/vendor/github.com/docker/docker/client/plugin_create.go +++ b/vendor/github.com/docker/docker/client/plugin_create.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/http" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // PluginCreate creates a plugin diff --git a/vendor/github.com/docker/docker/client/plugin_disable.go b/vendor/github.com/docker/docker/client/plugin_disable.go index 30467db742..01f6574f95 100644 --- a/vendor/github.com/docker/docker/client/plugin_disable.go +++ b/vendor/github.com/docker/docker/client/plugin_disable.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // PluginDisable disables a plugin diff --git a/vendor/github.com/docker/docker/client/plugin_enable.go b/vendor/github.com/docker/docker/client/plugin_enable.go index 95517c4b80..736da48bd1 100644 --- a/vendor/github.com/docker/docker/client/plugin_enable.go +++ b/vendor/github.com/docker/docker/client/plugin_enable.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "strconv" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // PluginEnable enables a plugin diff --git a/vendor/github.com/docker/docker/client/plugin_inspect.go b/vendor/github.com/docker/docker/client/plugin_inspect.go index 6a6fc18dfe..0ab7beaee8 100644 --- a/vendor/github.com/docker/docker/client/plugin_inspect.go +++ b/vendor/github.com/docker/docker/client/plugin_inspect.go @@ -1,16 +1,19 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // PluginInspectWithRaw inspects an existing plugin func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { + if name == "" { + return nil, nil, objectNotFoundError{object: "plugin", id: name} + } resp, err := cli.get(ctx, "/plugins/"+name+"/json", nil, nil) if err != nil { return nil, nil, wrapResponseError(err, resp, "plugin", name) diff --git a/vendor/github.com/docker/docker/client/plugin_install.go b/vendor/github.com/docker/docker/client/plugin_install.go index ce3e0506e5..13baa40a9b 100644 --- a/vendor/github.com/docker/docker/client/plugin_install.go +++ b/vendor/github.com/docker/docker/client/plugin_install.go @@ -1,6 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "io" "net/http" @@ -9,7 +10,6 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/pkg/errors" - "golang.org/x/net/context" ) // PluginInstall installs a plugin diff --git a/vendor/github.com/docker/docker/client/plugin_list.go b/vendor/github.com/docker/docker/client/plugin_list.go index 78dbeb8be3..ade1051a97 100644 --- a/vendor/github.com/docker/docker/client/plugin_list.go +++ b/vendor/github.com/docker/docker/client/plugin_list.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // PluginList returns the installed plugins diff --git a/vendor/github.com/docker/docker/client/plugin_push.go b/vendor/github.com/docker/docker/client/plugin_push.go index 1e5f963251..d20bfe8447 100644 --- a/vendor/github.com/docker/docker/client/plugin_push.go +++ b/vendor/github.com/docker/docker/client/plugin_push.go @@ -1,9 +1,8 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" - - "golang.org/x/net/context" ) // PluginPush pushes a plugin to a registry diff --git a/vendor/github.com/docker/docker/client/plugin_remove.go b/vendor/github.com/docker/docker/client/plugin_remove.go index b498c48203..8563bab0db 100644 --- a/vendor/github.com/docker/docker/client/plugin_remove.go +++ b/vendor/github.com/docker/docker/client/plugin_remove.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // PluginRemove removes a plugin diff --git a/vendor/github.com/docker/docker/client/plugin_set.go b/vendor/github.com/docker/docker/client/plugin_set.go index 3260d2a90d..dcf5752ca2 100644 --- a/vendor/github.com/docker/docker/client/plugin_set.go +++ b/vendor/github.com/docker/docker/client/plugin_set.go @@ -1,7 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( - "golang.org/x/net/context" + "context" ) // PluginSet modifies settings for an existing plugin diff --git a/vendor/github.com/docker/docker/client/plugin_upgrade.go b/vendor/github.com/docker/docker/client/plugin_upgrade.go index 049ebfa2a5..115cea945b 100644 --- a/vendor/github.com/docker/docker/client/plugin_upgrade.go +++ b/vendor/github.com/docker/docker/client/plugin_upgrade.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/pkg/errors" - "golang.org/x/net/context" ) // PluginUpgrade upgrades a plugin diff --git a/vendor/github.com/docker/docker/client/request.go b/vendor/github.com/docker/docker/client/request.go index 615d0b989d..52ed12446d 100644 --- a/vendor/github.com/docker/docker/client/request.go +++ b/vendor/github.com/docker/docker/client/request.go @@ -1,7 +1,8 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "fmt" "io" @@ -15,8 +16,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/pkg/errors" - "golang.org/x/net/context" - "golang.org/x/net/context/ctxhttp" ) // serverResponse is a wrapper for http API responses. @@ -123,23 +122,21 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u if err != nil { return resp, err } - if err := cli.checkResponseErr(resp); err != nil { - return resp, err - } - return resp, nil + return resp, cli.checkResponseErr(resp) } func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResponse, error) { serverResp := serverResponse{statusCode: -1, reqURL: req.URL} - resp, err := ctxhttp.Do(ctx, cli.client, req) + req = req.WithContext(ctx) + resp, err := cli.client.Do(req) if err != nil { if cli.scheme != "https" && strings.Contains(err.Error(), "malformed HTTP response") { return serverResp, fmt.Errorf("%v.\n* Are you trying to connect to a TLS-enabled daemon without TLS?", err) } if cli.scheme == "https" && strings.Contains(err.Error(), "bad certificate") { - return serverResp, fmt.Errorf("The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: %v", err) + return serverResp, errors.Wrap(err, "The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings") } // Don't decorate context sentinel errors; users may be comparing to @@ -198,9 +195,21 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error { return nil } - body, err := ioutil.ReadAll(serverResp.body) - if err != nil { - return err + var body []byte + var err error + if serverResp.body != nil { + bodyMax := 1 * 1024 * 1024 // 1 MiB + bodyR := &io.LimitedReader{ + R: serverResp.body, + N: int64(bodyMax), + } + body, err = ioutil.ReadAll(bodyR) + if err != nil { + return err + } + if bodyR.N == 0 { + return fmt.Errorf("request returned %s with a message (> %d bytes) for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), bodyMax, serverResp.reqURL) + } } if len(body) == 0 { return fmt.Errorf("request returned %s for API route and version %s, check if the server supports the requested API version", http.StatusText(serverResp.statusCode), serverResp.reqURL) @@ -215,14 +224,14 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error { if (cli.version == "" || versions.GreaterThan(cli.version, "1.23")) && ct == "application/json" { var errorResponse types.ErrorResponse if err := json.Unmarshal(body, &errorResponse); err != nil { - return fmt.Errorf("Error reading JSON: %v", err) + return errors.Wrap(err, "Error reading JSON") } - errorMessage = errorResponse.Message + errorMessage = strings.TrimSpace(errorResponse.Message) } else { - errorMessage = string(body) + errorMessage = strings.TrimSpace(string(body)) } - return fmt.Errorf("Error response from daemon: %s", strings.TrimSpace(errorMessage)) + return errors.Wrap(errors.New(errorMessage), "Error response from daemon") } func (cli *Client) addHeaders(req *http.Request, headers headers) *http.Request { diff --git a/vendor/github.com/docker/docker/client/secret_create.go b/vendor/github.com/docker/docker/client/secret_create.go index 4354afea60..09fae82f2a 100644 --- a/vendor/github.com/docker/docker/client/secret_create.go +++ b/vendor/github.com/docker/docker/client/secret_create.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SecretCreate creates a new Secret. diff --git a/vendor/github.com/docker/docker/client/secret_inspect.go b/vendor/github.com/docker/docker/client/secret_inspect.go index 6927ea96fa..e8322f4589 100644 --- a/vendor/github.com/docker/docker/client/secret_inspect.go +++ b/vendor/github.com/docker/docker/client/secret_inspect.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SecretInspectWithRaw returns the secret information with raw data @@ -14,6 +14,9 @@ func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.S if err := cli.NewVersionError("1.25", "secret inspect"); err != nil { return swarm.Secret{}, nil, err } + if id == "" { + return swarm.Secret{}, nil, objectNotFoundError{object: "secret", id: id} + } resp, err := cli.get(ctx, "/secrets/"+id, nil, nil) if err != nil { return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id) diff --git a/vendor/github.com/docker/docker/client/secret_list.go b/vendor/github.com/docker/docker/client/secret_list.go index fdee6e2e0b..f6bf7ba470 100644 --- a/vendor/github.com/docker/docker/client/secret_list.go +++ b/vendor/github.com/docker/docker/client/secret_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SecretList returns the list of secrets. diff --git a/vendor/github.com/docker/docker/client/secret_remove.go b/vendor/github.com/docker/docker/client/secret_remove.go index 9b4ee71e2c..e9d5218293 100644 --- a/vendor/github.com/docker/docker/client/secret_remove.go +++ b/vendor/github.com/docker/docker/client/secret_remove.go @@ -1,6 +1,6 @@ -package client +package client // import "github.com/docker/docker/client" -import "golang.org/x/net/context" +import "context" // SecretRemove removes a Secret. func (cli *Client) SecretRemove(ctx context.Context, id string) error { diff --git a/vendor/github.com/docker/docker/client/secret_update.go b/vendor/github.com/docker/docker/client/secret_update.go index 875a4c901e..164256bbc1 100644 --- a/vendor/github.com/docker/docker/client/secret_update.go +++ b/vendor/github.com/docker/docker/client/secret_update.go @@ -1,11 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "strconv" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SecretUpdate attempts to update a Secret diff --git a/vendor/github.com/docker/docker/client/service_create.go b/vendor/github.com/docker/docker/client/service_create.go index 834709d1f3..8fadda4a90 100644 --- a/vendor/github.com/docker/docker/client/service_create.go +++ b/vendor/github.com/docker/docker/client/service_create.go @@ -1,6 +1,7 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "strings" @@ -8,9 +9,8 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - digest "github.com/opencontainers/go-digest" + "github.com/opencontainers/go-digest" "github.com/pkg/errors" - "golang.org/x/net/context" ) // ServiceCreate creates a new Service. @@ -136,7 +136,7 @@ func imageWithDigestString(image string, dgst digest.Digest) string { // imageWithTagString takes an image string, and returns a tagged image // string, adding a 'latest' tag if one was not provided. It returns an -// emptry string if a canonical reference was provided +// empty string if a canonical reference was provided func imageWithTagString(image string) string { namedRef, err := reference.ParseNormalizedNamed(image) if err == nil { diff --git a/vendor/github.com/docker/docker/client/service_inspect.go b/vendor/github.com/docker/docker/client/service_inspect.go index 3e9699e5e0..de6aa22de7 100644 --- a/vendor/github.com/docker/docker/client/service_inspect.go +++ b/vendor/github.com/docker/docker/client/service_inspect.go @@ -1,7 +1,8 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "fmt" "io/ioutil" @@ -9,11 +10,13 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // ServiceInspectWithRaw returns the service information and the raw data. func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) { + if serviceID == "" { + return swarm.Service{}, nil, objectNotFoundError{object: "service", id: serviceID} + } query := url.Values{} query.Set("insertDefaults", fmt.Sprintf("%v", opts.InsertDefaults)) serverResp, err := cli.get(ctx, "/services/"+serviceID, query, nil) diff --git a/vendor/github.com/docker/docker/client/service_list.go b/vendor/github.com/docker/docker/client/service_list.go index eb3ff9739c..7d53e2b9b9 100644 --- a/vendor/github.com/docker/docker/client/service_list.go +++ b/vendor/github.com/docker/docker/client/service_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // ServiceList returns the list of services. diff --git a/vendor/github.com/docker/docker/client/service_logs.go b/vendor/github.com/docker/docker/client/service_logs.go index 24384e3ec0..906fd4059e 100644 --- a/vendor/github.com/docker/docker/client/service_logs.go +++ b/vendor/github.com/docker/docker/client/service_logs.go @@ -1,14 +1,14 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" "time" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" timetypes "github.com/docker/docker/api/types/time" + "github.com/pkg/errors" ) // ServiceLogs returns the logs generated by a service in an io.ReadCloser. @@ -26,7 +26,7 @@ func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options ty if options.Since != "" { ts, err := timetypes.GetTimestamp(options.Since, time.Now()) if err != nil { - return nil, err + return nil, errors.Wrap(err, `invalid value for "since"`) } query.Set("since", ts) } diff --git a/vendor/github.com/docker/docker/client/service_remove.go b/vendor/github.com/docker/docker/client/service_remove.go index ad992c01d0..fe3421bec8 100644 --- a/vendor/github.com/docker/docker/client/service_remove.go +++ b/vendor/github.com/docker/docker/client/service_remove.go @@ -1,6 +1,6 @@ -package client +package client // import "github.com/docker/docker/client" -import "golang.org/x/net/context" +import "context" // ServiceRemove kills and removes a service. func (cli *Client) ServiceRemove(ctx context.Context, serviceID string) error { diff --git a/vendor/github.com/docker/docker/client/service_update.go b/vendor/github.com/docker/docker/client/service_update.go index 8764f299a3..3c21214f60 100644 --- a/vendor/github.com/docker/docker/client/service_update.go +++ b/vendor/github.com/docker/docker/client/service_update.go @@ -1,16 +1,18 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "strconv" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) -// ServiceUpdate updates a Service. +// ServiceUpdate updates a Service. The version number is required to avoid conflicting writes. +// It should be the value as set *before* the update. You can find this value in the Meta field +// of swarm.Service, which can be found using ServiceInspectWithRaw. func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { var ( query = url.Values{} diff --git a/vendor/github.com/docker/docker/client/session.go b/vendor/github.com/docker/docker/client/session.go index 8ee9162136..df199f3d03 100644 --- a/vendor/github.com/docker/docker/client/session.go +++ b/vendor/github.com/docker/docker/client/session.go @@ -1,10 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net" "net/http" - - "golang.org/x/net/context" ) // DialSession returns a connection that can be used communication with daemon @@ -15,5 +14,5 @@ func (cli *Client) DialSession(ctx context.Context, proto string, meta map[strin } req = cli.addHeaders(req, meta) - return cli.setupHijackConn(req, proto) + return cli.setupHijackConn(ctx, req, proto) } diff --git a/vendor/github.com/docker/docker/client/swarm_get_unlock_key.go b/vendor/github.com/docker/docker/client/swarm_get_unlock_key.go index be28d32628..0c50c01a8c 100644 --- a/vendor/github.com/docker/docker/client/swarm_get_unlock_key.go +++ b/vendor/github.com/docker/docker/client/swarm_get_unlock_key.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // SwarmGetUnlockKey retrieves the swarm's unlock key. diff --git a/vendor/github.com/docker/docker/client/swarm_init.go b/vendor/github.com/docker/docker/client/swarm_init.go index 9e65e1cca4..742ca0f041 100644 --- a/vendor/github.com/docker/docker/client/swarm_init.go +++ b/vendor/github.com/docker/docker/client/swarm_init.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SwarmInit initializes the swarm. diff --git a/vendor/github.com/docker/docker/client/swarm_inspect.go b/vendor/github.com/docker/docker/client/swarm_inspect.go index 77e72f8466..cfaabb25b1 100644 --- a/vendor/github.com/docker/docker/client/swarm_inspect.go +++ b/vendor/github.com/docker/docker/client/swarm_inspect.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SwarmInspect inspects the swarm. diff --git a/vendor/github.com/docker/docker/client/swarm_join.go b/vendor/github.com/docker/docker/client/swarm_join.go index 19e5192b9e..a1cf0455d2 100644 --- a/vendor/github.com/docker/docker/client/swarm_join.go +++ b/vendor/github.com/docker/docker/client/swarm_join.go @@ -1,8 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SwarmJoin joins the swarm. diff --git a/vendor/github.com/docker/docker/client/swarm_leave.go b/vendor/github.com/docker/docker/client/swarm_leave.go index 3a205cf3b5..90ca84b363 100644 --- a/vendor/github.com/docker/docker/client/swarm_leave.go +++ b/vendor/github.com/docker/docker/client/swarm_leave.go @@ -1,9 +1,8 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" - - "golang.org/x/net/context" ) // SwarmLeave leaves the swarm. diff --git a/vendor/github.com/docker/docker/client/swarm_unlock.go b/vendor/github.com/docker/docker/client/swarm_unlock.go index 9ee441fed2..d2412f7d44 100644 --- a/vendor/github.com/docker/docker/client/swarm_unlock.go +++ b/vendor/github.com/docker/docker/client/swarm_unlock.go @@ -1,8 +1,9 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" + "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SwarmUnlock unlocks locked swarm. diff --git a/vendor/github.com/docker/docker/client/swarm_update.go b/vendor/github.com/docker/docker/client/swarm_update.go index 7245fd4e38..56a5bea761 100644 --- a/vendor/github.com/docker/docker/client/swarm_update.go +++ b/vendor/github.com/docker/docker/client/swarm_update.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "fmt" "net/url" "strconv" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // SwarmUpdate updates the swarm. diff --git a/vendor/github.com/docker/docker/client/task_inspect.go b/vendor/github.com/docker/docker/client/task_inspect.go index dc08cedb96..e1c0a736da 100644 --- a/vendor/github.com/docker/docker/client/task_inspect.go +++ b/vendor/github.com/docker/docker/client/task_inspect.go @@ -1,16 +1,19 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // TaskInspectWithRaw returns the task information and its raw representation.. func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) { + if taskID == "" { + return swarm.Task{}, nil, objectNotFoundError{object: "task", id: taskID} + } serverResp, err := cli.get(ctx, "/tasks/"+taskID, nil, nil) if err != nil { return swarm.Task{}, nil, wrapResponseError(err, serverResp, "task", taskID) diff --git a/vendor/github.com/docker/docker/client/task_list.go b/vendor/github.com/docker/docker/client/task_list.go index 01bd695257..42d20c1b8d 100644 --- a/vendor/github.com/docker/docker/client/task_list.go +++ b/vendor/github.com/docker/docker/client/task_list.go @@ -1,13 +1,13 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "golang.org/x/net/context" ) // TaskList returns the list of tasks. diff --git a/vendor/github.com/docker/docker/client/task_logs.go b/vendor/github.com/docker/docker/client/task_logs.go index 2ed19543a4..6222fab577 100644 --- a/vendor/github.com/docker/docker/client/task_logs.go +++ b/vendor/github.com/docker/docker/client/task_logs.go @@ -1,12 +1,11 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "io" "net/url" "time" - "golang.org/x/net/context" - "github.com/docker/docker/api/types" timetypes "github.com/docker/docker/api/types/time" ) diff --git a/vendor/github.com/docker/docker/client/tlsconfig_clone.go b/vendor/github.com/docker/docker/client/tlsconfig_clone.go deleted file mode 100644 index 99b6be1cea..0000000000 --- a/vendor/github.com/docker/docker/client/tlsconfig_clone.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build go1.8 - -package client - -import "crypto/tls" - -// tlsConfigClone returns a clone of tls.Config. This function is provided for -// compatibility for go1.7 that doesn't include this method in stdlib. -func tlsConfigClone(c *tls.Config) *tls.Config { - return c.Clone() -} diff --git a/vendor/github.com/docker/docker/client/tlsconfig_clone_go17.go b/vendor/github.com/docker/docker/client/tlsconfig_clone_go17.go deleted file mode 100644 index b837b2ade0..0000000000 --- a/vendor/github.com/docker/docker/client/tlsconfig_clone_go17.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build go1.7,!go1.8 - -package client - -import "crypto/tls" - -// tlsConfigClone returns a clone of tls.Config. This function is provided for -// compatibility for go1.7 that doesn't include this method in stdlib. -func tlsConfigClone(c *tls.Config) *tls.Config { - return &tls.Config{ - Rand: c.Rand, - Time: c.Time, - Certificates: c.Certificates, - NameToCertificate: c.NameToCertificate, - GetCertificate: c.GetCertificate, - RootCAs: c.RootCAs, - NextProtos: c.NextProtos, - ServerName: c.ServerName, - ClientAuth: c.ClientAuth, - ClientCAs: c.ClientCAs, - InsecureSkipVerify: c.InsecureSkipVerify, - CipherSuites: c.CipherSuites, - PreferServerCipherSuites: c.PreferServerCipherSuites, - SessionTicketsDisabled: c.SessionTicketsDisabled, - SessionTicketKey: c.SessionTicketKey, - ClientSessionCache: c.ClientSessionCache, - MinVersion: c.MinVersion, - MaxVersion: c.MaxVersion, - CurvePreferences: c.CurvePreferences, - DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, - Renegotiation: c.Renegotiation, - } -} diff --git a/vendor/github.com/docker/docker/client/transport.go b/vendor/github.com/docker/docker/client/transport.go index 73f6ef7b4d..5541344366 100644 --- a/vendor/github.com/docker/docker/client/transport.go +++ b/vendor/github.com/docker/docker/client/transport.go @@ -1,4 +1,4 @@ -package client +package client // import "github.com/docker/docker/client" import ( "crypto/tls" diff --git a/vendor/github.com/docker/docker/client/utils.go b/vendor/github.com/docker/docker/client/utils.go index 137705065c..7f3ff44eb8 100644 --- a/vendor/github.com/docker/docker/client/utils.go +++ b/vendor/github.com/docker/docker/client/utils.go @@ -1,4 +1,4 @@ -package client +package client // import "github.com/docker/docker/client" import ( "net/url" diff --git a/vendor/github.com/docker/docker/client/version.go b/vendor/github.com/docker/docker/client/version.go index 933ceb4a49..1989f6d6d2 100644 --- a/vendor/github.com/docker/docker/client/version.go +++ b/vendor/github.com/docker/docker/client/version.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // ServerVersion returns information of the docker client and server host. diff --git a/vendor/github.com/docker/docker/client/volume_create.go b/vendor/github.com/docker/docker/client/volume_create.go index 9620c87cbf..f1f6fcdc4a 100644 --- a/vendor/github.com/docker/docker/client/volume_create.go +++ b/vendor/github.com/docker/docker/client/volume_create.go @@ -1,15 +1,15 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "github.com/docker/docker/api/types" volumetypes "github.com/docker/docker/api/types/volume" - "golang.org/x/net/context" ) // VolumeCreate creates a volume in the docker host. -func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error) { +func (cli *Client) VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error) { var volume types.Volume resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) if err != nil { diff --git a/vendor/github.com/docker/docker/client/volume_inspect.go b/vendor/github.com/docker/docker/client/volume_inspect.go index 9889343849..f840682d2e 100644 --- a/vendor/github.com/docker/docker/client/volume_inspect.go +++ b/vendor/github.com/docker/docker/client/volume_inspect.go @@ -1,13 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( "bytes" + "context" "encoding/json" "io/ioutil" - "path" "github.com/docker/docker/api/types" - "golang.org/x/net/context" ) // VolumeInspect returns the information about a specific volume in the docker host. @@ -18,15 +17,12 @@ func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Vo // VolumeInspectWithRaw returns the information about a specific volume in the docker host and its raw representation func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) { - // The empty ID needs to be handled here because with an empty ID the - // request url will not contain a trailing / which calls the volume list API - // instead of volume inspect if volumeID == "" { return types.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID} } var volume types.Volume - resp, err := cli.get(ctx, path.Join("/volumes", volumeID), nil, nil) + resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil) if err != nil { return volume, nil, wrapResponseError(err, resp, "volume", volumeID) } diff --git a/vendor/github.com/docker/docker/client/volume_list.go b/vendor/github.com/docker/docker/client/volume_list.go index 32247ce115..284554d67c 100644 --- a/vendor/github.com/docker/docker/client/volume_list.go +++ b/vendor/github.com/docker/docker/client/volume_list.go @@ -1,17 +1,17 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "net/url" "github.com/docker/docker/api/types/filters" volumetypes "github.com/docker/docker/api/types/volume" - "golang.org/x/net/context" ) // VolumeList returns the volumes configured in the docker host. -func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error) { - var volumes volumetypes.VolumesListOKBody +func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error) { + var volumes volumetypes.VolumeListOKBody query := url.Values{} if filter.Len() > 0 { diff --git a/vendor/github.com/docker/docker/client/volume_prune.go b/vendor/github.com/docker/docker/client/volume_prune.go index 2e7fea7747..70041efed8 100644 --- a/vendor/github.com/docker/docker/client/volume_prune.go +++ b/vendor/github.com/docker/docker/client/volume_prune.go @@ -1,12 +1,12 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "encoding/json" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "golang.org/x/net/context" ) // VolumesPrune requests the daemon to delete unused data diff --git a/vendor/github.com/docker/docker/client/volume_remove.go b/vendor/github.com/docker/docker/client/volume_remove.go index 3ffb8bcf2e..fc5a71d334 100644 --- a/vendor/github.com/docker/docker/client/volume_remove.go +++ b/vendor/github.com/docker/docker/client/volume_remove.go @@ -1,10 +1,10 @@ -package client +package client // import "github.com/docker/docker/client" import ( + "context" "net/url" "github.com/docker/docker/api/types/versions" - "golang.org/x/net/context" ) // VolumeRemove removes a volume from the docker host. diff --git a/vendor/github.com/docker/docker/errdefs/defs.go b/vendor/github.com/docker/docker/errdefs/defs.go new file mode 100644 index 0000000000..e6a2275b2d --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/defs.go @@ -0,0 +1,74 @@ +package errdefs // import "github.com/docker/docker/errdefs" + +// ErrNotFound signals that the requested object doesn't exist +type ErrNotFound interface { + NotFound() +} + +// ErrInvalidParameter signals that the user input is invalid +type ErrInvalidParameter interface { + InvalidParameter() +} + +// ErrConflict signals that some internal state conflicts with the requested action and can't be performed. +// A change in state should be able to clear this error. +type ErrConflict interface { + Conflict() +} + +// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action +type ErrUnauthorized interface { + Unauthorized() +} + +// ErrUnavailable signals that the requested action/subsystem is not available. +type ErrUnavailable interface { + Unavailable() +} + +// ErrForbidden signals that the requested action cannot be performed under any circumstances. +// When a ErrForbidden is returned, the caller should never retry the action. +type ErrForbidden interface { + Forbidden() +} + +// ErrSystem signals that some internal error occurred. +// An example of this would be a failed mount request. +type ErrSystem interface { + System() +} + +// ErrNotModified signals that an action can't be performed because it's already in the desired state +type ErrNotModified interface { + NotModified() +} + +// ErrAlreadyExists is a special case of ErrConflict which signals that the desired object already exists +type ErrAlreadyExists interface { + AlreadyExists() +} + +// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured. +type ErrNotImplemented interface { + NotImplemented() +} + +// ErrUnknown signals that the kind of error that occurred is not known. +type ErrUnknown interface { + Unknown() +} + +// ErrCancelled signals that the action was cancelled. +type ErrCancelled interface { + Cancelled() +} + +// ErrDeadline signals that the deadline was reached before the action completed. +type ErrDeadline interface { + DeadlineExceeded() +} + +// ErrDataLoss indicates that data was lost or there is data corruption. +type ErrDataLoss interface { + DataLoss() +} diff --git a/vendor/github.com/docker/docker/errdefs/doc.go b/vendor/github.com/docker/docker/errdefs/doc.go new file mode 100644 index 0000000000..c211f174fc --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/doc.go @@ -0,0 +1,8 @@ +// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. +// Errors that cross the package boundary should implement one (and only one) of these interfaces. +// +// Packages should not reference these interfaces directly, only implement them. +// To check if a particular error implements one of these interfaces, there are helper +// functions provided (e.g. `Is`) which can be used rather than asserting the interfaces directly. +// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`). +package errdefs // import "github.com/docker/docker/errdefs" diff --git a/vendor/github.com/docker/docker/errdefs/helpers.go b/vendor/github.com/docker/docker/errdefs/helpers.go new file mode 100644 index 0000000000..a28881caf5 --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/helpers.go @@ -0,0 +1,243 @@ +package errdefs // import "github.com/docker/docker/errdefs" + +import "context" + +type errNotFound struct{ error } + +func (errNotFound) NotFound() {} + +func (e errNotFound) Cause() error { + return e.error +} + +// NotFound is a helper to create an error of the class with the same name from any error type +func NotFound(err error) error { + if err == nil || IsNotFound(err) { + return err + } + return errNotFound{err} +} + +type errInvalidParameter struct{ error } + +func (errInvalidParameter) InvalidParameter() {} + +func (e errInvalidParameter) Cause() error { + return e.error +} + +// InvalidParameter is a helper to create an error of the class with the same name from any error type +func InvalidParameter(err error) error { + if err == nil || IsInvalidParameter(err) { + return err + } + return errInvalidParameter{err} +} + +type errConflict struct{ error } + +func (errConflict) Conflict() {} + +func (e errConflict) Cause() error { + return e.error +} + +// Conflict is a helper to create an error of the class with the same name from any error type +func Conflict(err error) error { + if err == nil || IsConflict(err) { + return err + } + return errConflict{err} +} + +type errUnauthorized struct{ error } + +func (errUnauthorized) Unauthorized() {} + +func (e errUnauthorized) Cause() error { + return e.error +} + +// Unauthorized is a helper to create an error of the class with the same name from any error type +func Unauthorized(err error) error { + if err == nil || IsUnauthorized(err) { + return err + } + return errUnauthorized{err} +} + +type errUnavailable struct{ error } + +func (errUnavailable) Unavailable() {} + +func (e errUnavailable) Cause() error { + return e.error +} + +// Unavailable is a helper to create an error of the class with the same name from any error type +func Unavailable(err error) error { + if err == nil || IsUnavailable(err) { + return err + } + return errUnavailable{err} +} + +type errForbidden struct{ error } + +func (errForbidden) Forbidden() {} + +func (e errForbidden) Cause() error { + return e.error +} + +// Forbidden is a helper to create an error of the class with the same name from any error type +func Forbidden(err error) error { + if err == nil || IsForbidden(err) { + return err + } + return errForbidden{err} +} + +type errSystem struct{ error } + +func (errSystem) System() {} + +func (e errSystem) Cause() error { + return e.error +} + +// System is a helper to create an error of the class with the same name from any error type +func System(err error) error { + if err == nil || IsSystem(err) { + return err + } + return errSystem{err} +} + +type errNotModified struct{ error } + +func (errNotModified) NotModified() {} + +func (e errNotModified) Cause() error { + return e.error +} + +// NotModified is a helper to create an error of the class with the same name from any error type +func NotModified(err error) error { + if err == nil || IsNotModified(err) { + return err + } + return errNotModified{err} +} + +type errAlreadyExists struct{ error } + +func (errAlreadyExists) AlreadyExists() {} + +func (e errAlreadyExists) Cause() error { + return e.error +} + +// AlreadyExists is a helper to create an error of the class with the same name from any error type +func AlreadyExists(err error) error { + if err == nil || IsAlreadyExists(err) { + return err + } + return errAlreadyExists{err} +} + +type errNotImplemented struct{ error } + +func (errNotImplemented) NotImplemented() {} + +func (e errNotImplemented) Cause() error { + return e.error +} + +// NotImplemented is a helper to create an error of the class with the same name from any error type +func NotImplemented(err error) error { + if err == nil || IsNotImplemented(err) { + return err + } + return errNotImplemented{err} +} + +type errUnknown struct{ error } + +func (errUnknown) Unknown() {} + +func (e errUnknown) Cause() error { + return e.error +} + +// Unknown is a helper to create an error of the class with the same name from any error type +func Unknown(err error) error { + if err == nil || IsUnknown(err) { + return err + } + return errUnknown{err} +} + +type errCancelled struct{ error } + +func (errCancelled) Cancelled() {} + +func (e errCancelled) Cause() error { + return e.error +} + +// Cancelled is a helper to create an error of the class with the same name from any error type +func Cancelled(err error) error { + if err == nil || IsCancelled(err) { + return err + } + return errCancelled{err} +} + +type errDeadline struct{ error } + +func (errDeadline) DeadlineExceeded() {} + +func (e errDeadline) Cause() error { + return e.error +} + +// Deadline is a helper to create an error of the class with the same name from any error type +func Deadline(err error) error { + if err == nil || IsDeadline(err) { + return err + } + return errDeadline{err} +} + +type errDataLoss struct{ error } + +func (errDataLoss) DataLoss() {} + +func (e errDataLoss) Cause() error { + return e.error +} + +// DataLoss is a helper to create an error of the class with the same name from any error type +func DataLoss(err error) error { + if err == nil || IsDataLoss(err) { + return err + } + return errDataLoss{err} +} + +// FromContext returns the error class from the passed in context +func FromContext(ctx context.Context) error { + e := ctx.Err() + if e == nil { + return nil + } + + if e == context.Canceled { + return Cancelled(e) + } + if e == context.DeadlineExceeded { + return Deadline(e) + } + return Unknown(e) +} diff --git a/vendor/github.com/docker/docker/errdefs/is.go b/vendor/github.com/docker/docker/errdefs/is.go new file mode 100644 index 0000000000..e0513331bb --- /dev/null +++ b/vendor/github.com/docker/docker/errdefs/is.go @@ -0,0 +1,114 @@ +package errdefs // import "github.com/docker/docker/errdefs" + +type causer interface { + Cause() error +} + +func getImplementer(err error) error { + switch e := err.(type) { + case + ErrNotFound, + ErrInvalidParameter, + ErrConflict, + ErrUnauthorized, + ErrUnavailable, + ErrForbidden, + ErrSystem, + ErrNotModified, + ErrAlreadyExists, + ErrNotImplemented, + ErrCancelled, + ErrDeadline, + ErrDataLoss, + ErrUnknown: + return err + case causer: + return getImplementer(e.Cause()) + default: + return err + } +} + +// IsNotFound returns if the passed in error is an ErrNotFound +func IsNotFound(err error) bool { + _, ok := getImplementer(err).(ErrNotFound) + return ok +} + +// IsInvalidParameter returns if the passed in error is an ErrInvalidParameter +func IsInvalidParameter(err error) bool { + _, ok := getImplementer(err).(ErrInvalidParameter) + return ok +} + +// IsConflict returns if the passed in error is an ErrConflict +func IsConflict(err error) bool { + _, ok := getImplementer(err).(ErrConflict) + return ok +} + +// IsUnauthorized returns if the passed in error is an ErrUnauthorized +func IsUnauthorized(err error) bool { + _, ok := getImplementer(err).(ErrUnauthorized) + return ok +} + +// IsUnavailable returns if the passed in error is an ErrUnavailable +func IsUnavailable(err error) bool { + _, ok := getImplementer(err).(ErrUnavailable) + return ok +} + +// IsForbidden returns if the passed in error is an ErrForbidden +func IsForbidden(err error) bool { + _, ok := getImplementer(err).(ErrForbidden) + return ok +} + +// IsSystem returns if the passed in error is an ErrSystem +func IsSystem(err error) bool { + _, ok := getImplementer(err).(ErrSystem) + return ok +} + +// IsNotModified returns if the passed in error is a NotModified error +func IsNotModified(err error) bool { + _, ok := getImplementer(err).(ErrNotModified) + return ok +} + +// IsAlreadyExists returns if the passed in error is a AlreadyExists error +func IsAlreadyExists(err error) bool { + _, ok := getImplementer(err).(ErrAlreadyExists) + return ok +} + +// IsNotImplemented returns if the passed in error is an ErrNotImplemented +func IsNotImplemented(err error) bool { + _, ok := getImplementer(err).(ErrNotImplemented) + return ok +} + +// IsUnknown returns if the passed in error is an ErrUnknown +func IsUnknown(err error) bool { + _, ok := getImplementer(err).(ErrUnknown) + return ok +} + +// IsCancelled returns if the passed in error is an ErrCancelled +func IsCancelled(err error) bool { + _, ok := getImplementer(err).(ErrCancelled) + return ok +} + +// IsDeadline returns if the passed in error is an ErrDeadline +func IsDeadline(err error) bool { + _, ok := getImplementer(err).(ErrDeadline) + return ok +} + +// IsDataLoss returns if the passed in error is an ErrDataLoss +func IsDataLoss(err error) bool { + _, ok := getImplementer(err).(ErrDataLoss) + return ok +} diff --git a/vendor/github.com/docker/docker/opts/address_pools.go b/vendor/github.com/docker/docker/opts/address_pools.go new file mode 100644 index 0000000000..9b27a62853 --- /dev/null +++ b/vendor/github.com/docker/docker/opts/address_pools.go @@ -0,0 +1,84 @@ +package opts + +import ( + "encoding/csv" + "encoding/json" + "fmt" + "strconv" + "strings" + + types "github.com/docker/libnetwork/ipamutils" +) + +// PoolsOpt is a Value type for parsing the default address pools definitions +type PoolsOpt struct { + values []*types.NetworkToSplit +} + +// UnmarshalJSON fills values structure info from JSON input +func (p *PoolsOpt) UnmarshalJSON(raw []byte) error { + return json.Unmarshal(raw, &(p.values)) +} + +// Set predefined pools +func (p *PoolsOpt) Set(value string) error { + csvReader := csv.NewReader(strings.NewReader(value)) + fields, err := csvReader.Read() + if err != nil { + return err + } + + poolsDef := types.NetworkToSplit{} + + for _, field := range fields { + parts := strings.SplitN(field, "=", 2) + if len(parts) != 2 { + return fmt.Errorf("invalid field '%s' must be a key=value pair", field) + } + + key := strings.ToLower(parts[0]) + value := strings.ToLower(parts[1]) + + switch key { + case "base": + poolsDef.Base = value + case "size": + size, err := strconv.Atoi(value) + if err != nil { + return fmt.Errorf("invalid size value: %q (must be integer): %v", value, err) + } + poolsDef.Size = size + default: + return fmt.Errorf("unexpected key '%s' in '%s'", key, field) + } + } + + p.values = append(p.values, &poolsDef) + + return nil +} + +// Type returns the type of this option +func (p *PoolsOpt) Type() string { + return "pool-options" +} + +// String returns a string repr of this option +func (p *PoolsOpt) String() string { + var pools []string + for _, pool := range p.values { + repr := fmt.Sprintf("%s %d", pool.Base, pool.Size) + pools = append(pools, repr) + } + return strings.Join(pools, ", ") +} + +// Value returns the mounts +func (p *PoolsOpt) Value() []*types.NetworkToSplit { + return p.values +} + +// Name returns the flag name of this option +func (p *PoolsOpt) Name() string { + return "default-address-pools" +} diff --git a/vendor/github.com/docker/docker/opts/env.go b/vendor/github.com/docker/docker/opts/env.go index 4fbd470bcf..f6e5e9074d 100644 --- a/vendor/github.com/docker/docker/opts/env.go +++ b/vendor/github.com/docker/docker/opts/env.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" import ( "fmt" diff --git a/vendor/github.com/docker/docker/opts/hosts.go b/vendor/github.com/docker/docker/opts/hosts.go index 594cccf2fb..3d8785f11c 100644 --- a/vendor/github.com/docker/docker/opts/hosts.go +++ b/vendor/github.com/docker/docker/opts/hosts.go @@ -1,11 +1,14 @@ -package opts +package opts // import "github.com/docker/docker/opts" import ( "fmt" "net" "net/url" + "path/filepath" "strconv" "strings" + + "github.com/docker/docker/pkg/homedir" ) var ( @@ -29,9 +32,9 @@ var ( // ValidateHost validates that the specified string is a valid host and returns it. func ValidateHost(val string) (string, error) { host := strings.TrimSpace(val) - // The empty string means default and is not handled by parseDockerDaemonHost + // The empty string means default and is not handled by parseDaemonHost if host != "" { - _, err := parseDockerDaemonHost(host) + _, err := parseDaemonHost(host) if err != nil { return val, err } @@ -41,18 +44,26 @@ func ValidateHost(val string) (string, error) { return val, nil } -// ParseHost and set defaults for a Daemon host string -func ParseHost(defaultToTLS bool, val string) (string, error) { +// ParseHost and set defaults for a Daemon host string. +// defaultToTLS is preferred over defaultToUnixRootless. +func ParseHost(defaultToTLS, defaultToUnixRootless bool, val string) (string, error) { host := strings.TrimSpace(val) if host == "" { if defaultToTLS { host = DefaultTLSHost + } else if defaultToUnixRootless { + runtimeDir, err := homedir.GetRuntimeDir() + if err != nil { + return "", err + } + socket := filepath.Join(runtimeDir, "docker.sock") + host = "unix://" + socket } else { host = DefaultHost } } else { var err error - host, err = parseDockerDaemonHost(host) + host, err = parseDaemonHost(host) if err != nil { return val, err } @@ -60,9 +71,9 @@ func ParseHost(defaultToTLS bool, val string) (string, error) { return host, nil } -// parseDockerDaemonHost parses the specified address and returns an address that will be used as the host. +// parseDaemonHost parses the specified address and returns an address that will be used as the host. // Depending of the address specified, this may return one of the global Default* strings defined in hosts.go. -func parseDockerDaemonHost(addr string) (string, error) { +func parseDaemonHost(addr string) (string, error) { addrParts := strings.SplitN(addr, "://", 2) if len(addrParts) == 1 && addrParts[0] != "" { addrParts = []string{"tcp", addrParts[0]} diff --git a/vendor/github.com/docker/docker/opts/hosts_unix.go b/vendor/github.com/docker/docker/opts/hosts_unix.go index 611407a9d9..9d5bb64565 100644 --- a/vendor/github.com/docker/docker/opts/hosts_unix.go +++ b/vendor/github.com/docker/docker/opts/hosts_unix.go @@ -1,6 +1,6 @@ // +build !windows -package opts +package opts // import "github.com/docker/docker/opts" import "fmt" diff --git a/vendor/github.com/docker/docker/opts/hosts_windows.go b/vendor/github.com/docker/docker/opts/hosts_windows.go index 7c239e00f1..906eba53ee 100644 --- a/vendor/github.com/docker/docker/opts/hosts_windows.go +++ b/vendor/github.com/docker/docker/opts/hosts_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package opts +package opts // import "github.com/docker/docker/opts" // DefaultHost constant defines the default host string used by docker on Windows var DefaultHost = "npipe://" + DefaultNamedPipe diff --git a/vendor/github.com/docker/docker/opts/ip.go b/vendor/github.com/docker/docker/opts/ip.go index 1095063977..cfbff3a9fd 100644 --- a/vendor/github.com/docker/docker/opts/ip.go +++ b/vendor/github.com/docker/docker/opts/ip.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" import ( "fmt" diff --git a/vendor/github.com/docker/docker/opts/opts.go b/vendor/github.com/docker/docker/opts/opts.go index a86d74d60a..de8aacb806 100644 --- a/vendor/github.com/docker/docker/opts/opts.go +++ b/vendor/github.com/docker/docker/opts/opts.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" import ( "fmt" @@ -7,7 +7,7 @@ import ( "regexp" "strings" - units "github.com/docker/go-units" + "github.com/docker/go-units" ) var ( @@ -52,7 +52,7 @@ func (opts *ListOpts) Set(value string) error { } value = v } - (*opts.values) = append((*opts.values), value) + *opts.values = append(*opts.values, value) return nil } @@ -60,7 +60,7 @@ func (opts *ListOpts) Set(value string) error { func (opts *ListOpts) Delete(key string) { for i, k := range *opts.values { if k == key { - (*opts.values) = append((*opts.values)[:i], (*opts.values)[i+1:]...) + *opts.values = append((*opts.values)[:i], (*opts.values)[i+1:]...) return } } @@ -78,7 +78,7 @@ func (opts *ListOpts) GetMap() map[string]struct{} { // GetAll returns the values of slice. func (opts *ListOpts) GetAll() []string { - return (*opts.values) + return *opts.values } // GetAllOrEmpty returns the values of the slice @@ -103,7 +103,7 @@ func (opts *ListOpts) Get(key string) bool { // Len returns the amount of element in the slice. func (opts *ListOpts) Len() int { - return len((*opts.values)) + return len(*opts.values) } // Type returns a string name for this Option type @@ -263,6 +263,16 @@ func ValidateLabel(val string) (string, error) { return val, nil } +// ValidateSingleGenericResource validates that a single entry in the +// generic resource list is valid. +// i.e 'GPU=UID1' is valid however 'GPU:UID1' or 'UID1' isn't +func ValidateSingleGenericResource(val string) (string, error) { + if strings.Count(val, "=") < 1 { + return "", fmt.Errorf("invalid node-generic-resource format `%s` expected `name=value`", val) + } + return val, nil +} + // ParseLink parses and validates the specified string as a link format (name:alias) func ParseLink(val string) (string, string, error) { if val == "" { diff --git a/vendor/github.com/docker/docker/opts/opts_unix.go b/vendor/github.com/docker/docker/opts/opts_unix.go index 2766a43a08..0c32367cb2 100644 --- a/vendor/github.com/docker/docker/opts/opts_unix.go +++ b/vendor/github.com/docker/docker/opts/opts_unix.go @@ -1,6 +1,6 @@ // +build !windows -package opts +package opts // import "github.com/docker/docker/opts" // DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. dockerd -H tcp://:8080 const DefaultHTTPHost = "localhost" diff --git a/vendor/github.com/docker/docker/opts/opts_windows.go b/vendor/github.com/docker/docker/opts/opts_windows.go index 98b7251a9e..0e1b6c6d18 100644 --- a/vendor/github.com/docker/docker/opts/opts_windows.go +++ b/vendor/github.com/docker/docker/opts/opts_windows.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" // TODO Windows. Identify bug in GOLang 1.5.1+ and/or Windows Server 2016 TP5. // @jhowardmsft, @swernli. diff --git a/vendor/github.com/docker/docker/opts/quotedstring.go b/vendor/github.com/docker/docker/opts/quotedstring.go index 09c68a5261..6c889070e8 100644 --- a/vendor/github.com/docker/docker/opts/quotedstring.go +++ b/vendor/github.com/docker/docker/opts/quotedstring.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" // QuotedString is a string that may have extra quotes around the value. The // quotes are stripped from the value. diff --git a/vendor/github.com/docker/docker/opts/runtime.go b/vendor/github.com/docker/docker/opts/runtime.go index 4361b3ce09..4b9babf0a5 100644 --- a/vendor/github.com/docker/docker/opts/runtime.go +++ b/vendor/github.com/docker/docker/opts/runtime.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" import ( "fmt" diff --git a/vendor/github.com/docker/docker/opts/ulimit.go b/vendor/github.com/docker/docker/opts/ulimit.go index a2a65fcd21..0e2a36236c 100644 --- a/vendor/github.com/docker/docker/opts/ulimit.go +++ b/vendor/github.com/docker/docker/opts/ulimit.go @@ -1,4 +1,4 @@ -package opts +package opts // import "github.com/docker/docker/opts" import ( "fmt" diff --git a/vendor/github.com/docker/docker/pkg/README.md b/vendor/github.com/docker/docker/pkg/README.md index c4b78a8ad8..755cd96836 100644 --- a/vendor/github.com/docker/docker/pkg/README.md +++ b/vendor/github.com/docker/docker/pkg/README.md @@ -1,8 +1,8 @@ -pkg/ is a collection of utility packages used by the Docker project without being specific to its internals. +pkg/ is a collection of utility packages used by the Moby project without being specific to its internals. -Utility packages are kept separate from the docker core codebase to keep it as small and concise as possible. +Utility packages are kept separate from the moby core codebase to keep it as small and concise as possible. If some utilities grow larger and their APIs stabilize, they may be moved to their own repository under the -Docker organization, to facilitate re-use by other projects. However that is not the priority. +Moby organization, to facilitate re-use by other projects. However that is not the priority. The directory `pkg` is named after the same directory in the camlistore project. Since Brad is a core Go maintainer, we thought it made sense to copy his methods for organizing Go code :) Thanks Brad! diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils.go index a129e654ea..34f1c726fb 100644 --- a/vendor/github.com/docker/docker/pkg/fileutils/fileutils.go +++ b/vendor/github.com/docker/docker/pkg/fileutils/fileutils.go @@ -1,4 +1,4 @@ -package fileutils +package fileutils // import "github.com/docker/docker/pkg/fileutils" import ( "errors" @@ -13,7 +13,7 @@ import ( "github.com/sirupsen/logrus" ) -// PatternMatcher allows checking paths agaist a list of patterns +// PatternMatcher allows checking paths against a list of patterns type PatternMatcher struct { patterns []*Pattern exclusions bool @@ -106,7 +106,7 @@ func (pm *PatternMatcher) Patterns() []*Pattern { return pm.patterns } -// Pattern defines a single regexp used used to filter file paths. +// Pattern defines a single regexp used to filter file paths. type Pattern struct { cleanedPattern string dirs []string diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go index ccd648fac3..e40cc271b3 100644 --- a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go +++ b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go @@ -1,4 +1,4 @@ -package fileutils +package fileutils // import "github.com/docker/docker/pkg/fileutils" import ( "os" diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_solaris.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_solaris.go deleted file mode 100644 index 0f2cb7ab93..0000000000 --- a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_solaris.go +++ /dev/null @@ -1,7 +0,0 @@ -package fileutils - -// GetTotalUsedFds Returns the number of used File Descriptors. -// On Solaris these limits are per process and not systemwide -func GetTotalUsedFds() int { - return -1 -} diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_unix.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_unix.go index 9e0e97bd64..565396f1c7 100644 --- a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_unix.go +++ b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_unix.go @@ -1,6 +1,6 @@ // +build linux freebsd -package fileutils +package fileutils // import "github.com/docker/docker/pkg/fileutils" import ( "fmt" diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_windows.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_windows.go index 5ec21cace5..3f1ebb6567 100644 --- a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_windows.go +++ b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_windows.go @@ -1,4 +1,4 @@ -package fileutils +package fileutils // import "github.com/docker/docker/pkg/fileutils" // GetTotalUsedFds Returns the number of used File Descriptors. Not supported // on Windows. diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go index 012fe52a28..47ecd0c092 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go @@ -1,9 +1,10 @@ -// +build linux - -package homedir +package homedir // import "github.com/docker/docker/pkg/homedir" import ( + "errors" "os" + "path/filepath" + "strings" "github.com/docker/docker/pkg/idtools" ) @@ -21,3 +22,88 @@ func GetStatic() (string, error) { } return usr.Home, nil } + +// GetRuntimeDir returns XDG_RUNTIME_DIR. +// XDG_RUNTIME_DIR is typically configured via pam_systemd. +// GetRuntimeDir returns non-nil error if XDG_RUNTIME_DIR is not set. +// +// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html +func GetRuntimeDir() (string, error) { + if xdgRuntimeDir := os.Getenv("XDG_RUNTIME_DIR"); xdgRuntimeDir != "" { + return xdgRuntimeDir, nil + } + return "", errors.New("could not get XDG_RUNTIME_DIR") +} + +// StickRuntimeDirContents sets the sticky bit on files that are under +// XDG_RUNTIME_DIR, so that the files won't be periodically removed by the system. +// +// StickyRuntimeDir returns slice of sticked files. +// StickyRuntimeDir returns nil error if XDG_RUNTIME_DIR is not set. +// +// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html +func StickRuntimeDirContents(files []string) ([]string, error) { + runtimeDir, err := GetRuntimeDir() + if err != nil { + // ignore error if runtimeDir is empty + return nil, nil + } + runtimeDir, err = filepath.Abs(runtimeDir) + if err != nil { + return nil, err + } + var sticked []string + for _, f := range files { + f, err = filepath.Abs(f) + if err != nil { + return sticked, err + } + if strings.HasPrefix(f, runtimeDir+"/") { + if err = stick(f); err != nil { + return sticked, err + } + sticked = append(sticked, f) + } + } + return sticked, nil +} + +func stick(f string) error { + st, err := os.Stat(f) + if err != nil { + return err + } + m := st.Mode() + m |= os.ModeSticky + return os.Chmod(f, m) +} + +// GetDataHome returns XDG_DATA_HOME. +// GetDataHome returns $HOME/.local/share and nil error if XDG_DATA_HOME is not set. +// +// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html +func GetDataHome() (string, error) { + if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" { + return xdgDataHome, nil + } + home := os.Getenv("HOME") + if home == "" { + return "", errors.New("could not get either XDG_DATA_HOME or HOME") + } + return filepath.Join(home, ".local", "share"), nil +} + +// GetConfigHome returns XDG_CONFIG_HOME. +// GetConfigHome returns $HOME/.config and nil error if XDG_CONFIG_HOME is not set. +// +// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html +func GetConfigHome() (string, error) { + if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" { + return xdgConfigHome, nil + } + home := os.Getenv("HOME") + if home == "" { + return "", errors.New("could not get either XDG_CONFIG_HOME or HOME") + } + return filepath.Join(home, ".config"), nil +} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go index 6b96b856f6..f0a363dedf 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go @@ -1,6 +1,6 @@ // +build !linux -package homedir +package homedir // import "github.com/docker/docker/pkg/homedir" import ( "errors" @@ -11,3 +11,23 @@ import ( func GetStatic() (string, error) { return "", errors.New("homedir.GetStatic() is not supported on this system") } + +// GetRuntimeDir is unsupported on non-linux system. +func GetRuntimeDir() (string, error) { + return "", errors.New("homedir.GetRuntimeDir() is not supported on this system") +} + +// StickRuntimeDirContents is unsupported on non-linux system. +func StickRuntimeDirContents(files []string) ([]string, error) { + return nil, errors.New("homedir.StickRuntimeDirContents() is not supported on this system") +} + +// GetDataHome is unsupported on non-linux system. +func GetDataHome() (string, error) { + return "", errors.New("homedir.GetDataHome() is not supported on this system") +} + +// GetConfigHome is unsupported on non-linux system. +func GetConfigHome() (string, error) { + return "", errors.New("homedir.GetConfigHome() is not supported on this system") +} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go index f2a20ea8f8..d85e124488 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go @@ -1,6 +1,6 @@ // +build !windows -package homedir +package homedir // import "github.com/docker/docker/pkg/homedir" import ( "os" diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go index fafdb2bbf9..2f81813b28 100644 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go +++ b/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go @@ -1,4 +1,4 @@ -package homedir +package homedir // import "github.com/docker/docker/pkg/homedir" import ( "os" diff --git a/vendor/github.com/docker/docker/pkg/idtools/idtools.go b/vendor/github.com/docker/docker/pkg/idtools/idtools.go index 68a072db22..230422eac8 100644 --- a/vendor/github.com/docker/docker/pkg/idtools/idtools.go +++ b/vendor/github.com/docker/docker/pkg/idtools/idtools.go @@ -1,4 +1,4 @@ -package idtools +package idtools // import "github.com/docker/docker/pkg/idtools" import ( "bufio" @@ -30,43 +30,30 @@ func (e ranges) Swap(i, j int) { e[i], e[j] = e[j], e[i] } func (e ranges) Less(i, j int) bool { return e[i].Start < e[j].Start } const ( - subuidFileName string = "/etc/subuid" - subgidFileName string = "/etc/subgid" + subuidFileName = "/etc/subuid" + subgidFileName = "/etc/subgid" ) -// MkdirAllAs creates a directory (include any along the path) and then modifies -// ownership to the requested uid/gid. If the directory already exists, this -// function will still change ownership to the requested uid/gid pair. -// Deprecated: Use MkdirAllAndChown -func MkdirAllAs(path string, mode os.FileMode, ownerUID, ownerGID int) error { - return mkdirAs(path, mode, ownerUID, ownerGID, true, true) -} - -// MkdirAs creates a directory and then modifies ownership to the requested uid/gid. -// If the directory already exists, this function still changes ownership -// Deprecated: Use MkdirAndChown with a IDPair -func MkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int) error { - return mkdirAs(path, mode, ownerUID, ownerGID, false, true) -} - // MkdirAllAndChown creates a directory (include any along the path) and then modifies // ownership to the requested uid/gid. If the directory already exists, this // function will still change ownership to the requested uid/gid pair. -func MkdirAllAndChown(path string, mode os.FileMode, ids IDPair) error { - return mkdirAs(path, mode, ids.UID, ids.GID, true, true) +func MkdirAllAndChown(path string, mode os.FileMode, owner Identity) error { + return mkdirAs(path, mode, owner, true, true) } // MkdirAndChown creates a directory and then modifies ownership to the requested uid/gid. -// If the directory already exists, this function still changes ownership -func MkdirAndChown(path string, mode os.FileMode, ids IDPair) error { - return mkdirAs(path, mode, ids.UID, ids.GID, false, true) +// If the directory already exists, this function still changes ownership. +// Note that unlike os.Mkdir(), this function does not return IsExist error +// in case path already exists. +func MkdirAndChown(path string, mode os.FileMode, owner Identity) error { + return mkdirAs(path, mode, owner, false, true) } // MkdirAllAndChownNew creates a directory (include any along the path) and then modifies // ownership ONLY of newly created directories to the requested uid/gid. If the // directories along the path exist, no change of ownership will be performed -func MkdirAllAndChownNew(path string, mode os.FileMode, ids IDPair) error { - return mkdirAs(path, mode, ids.UID, ids.GID, true, false) +func MkdirAllAndChownNew(path string, mode os.FileMode, owner Identity) error { + return mkdirAs(path, mode, owner, true, false) } // GetRootUIDGID retrieves the remapped root uid/gid pair from the set of maps. @@ -115,22 +102,23 @@ func toHost(contID int, idMap []IDMap) (int, error) { return -1, fmt.Errorf("Container ID %d cannot be mapped to a host ID", contID) } -// IDPair is a UID and GID pair -type IDPair struct { +// Identity is either a UID and GID pair or a SID (but not both) +type Identity struct { UID int GID int + SID string } -// IDMappings contains a mappings of UIDs and GIDs -type IDMappings struct { +// IdentityMapping contains a mappings of UIDs and GIDs +type IdentityMapping struct { uids []IDMap gids []IDMap } -// NewIDMappings takes a requested user and group name and +// NewIdentityMapping takes a requested user and group name and // using the data from /etc/sub{uid,gid} ranges, creates the // proper uid and gid remapping ranges for that user/group pair -func NewIDMappings(username, groupname string) (*IDMappings, error) { +func NewIdentityMapping(username, groupname string) (*IdentityMapping, error) { subuidRanges, err := parseSubuid(username) if err != nil { return nil, err @@ -146,7 +134,7 @@ func NewIDMappings(username, groupname string) (*IDMappings, error) { return nil, fmt.Errorf("No subgid ranges found for group %q", groupname) } - return &IDMappings{ + return &IdentityMapping{ uids: createIDMap(subuidRanges), gids: createIDMap(subgidRanges), }, nil @@ -154,21 +142,21 @@ func NewIDMappings(username, groupname string) (*IDMappings, error) { // NewIDMappingsFromMaps creates a new mapping from two slices // Deprecated: this is a temporary shim while transitioning to IDMapping -func NewIDMappingsFromMaps(uids []IDMap, gids []IDMap) *IDMappings { - return &IDMappings{uids: uids, gids: gids} +func NewIDMappingsFromMaps(uids []IDMap, gids []IDMap) *IdentityMapping { + return &IdentityMapping{uids: uids, gids: gids} } // RootPair returns a uid and gid pair for the root user. The error is ignored // because a root user always exists, and the defaults are correct when the uid // and gid maps are empty. -func (i *IDMappings) RootPair() IDPair { +func (i *IdentityMapping) RootPair() Identity { uid, gid, _ := GetRootUIDGID(i.uids, i.gids) - return IDPair{UID: uid, GID: gid} + return Identity{UID: uid, GID: gid} } // ToHost returns the host UID and GID for the container uid, gid. // Remapping is only performed if the ids aren't already the remapped root ids -func (i *IDMappings) ToHost(pair IDPair) (IDPair, error) { +func (i *IdentityMapping) ToHost(pair Identity) (Identity, error) { var err error target := i.RootPair() @@ -186,7 +174,7 @@ func (i *IDMappings) ToHost(pair IDPair) (IDPair, error) { } // ToContainer returns the container UID and GID for the host uid and gid -func (i *IDMappings) ToContainer(pair IDPair) (int, int, error) { +func (i *IdentityMapping) ToContainer(pair Identity) (int, int, error) { uid, err := toContainer(pair.UID, i.uids) if err != nil { return -1, -1, err @@ -196,19 +184,19 @@ func (i *IDMappings) ToContainer(pair IDPair) (int, int, error) { } // Empty returns true if there are no id mappings -func (i *IDMappings) Empty() bool { +func (i *IdentityMapping) Empty() bool { return len(i.uids) == 0 && len(i.gids) == 0 } // UIDs return the UID mapping // TODO: remove this once everything has been refactored to use pairs -func (i *IDMappings) UIDs() []IDMap { +func (i *IdentityMapping) UIDs() []IDMap { return i.uids } // GIDs return the UID mapping // TODO: remove this once everything has been refactored to use pairs -func (i *IDMappings) GIDs() []IDMap { +func (i *IdentityMapping) GIDs() []IDMap { return i.gids } diff --git a/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go b/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go index 8701bb7fa9..fb239743a0 100644 --- a/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go +++ b/vendor/github.com/docker/docker/pkg/idtools/idtools_unix.go @@ -1,6 +1,6 @@ // +build !windows -package idtools +package idtools // import "github.com/docker/docker/pkg/idtools" import ( "bytes" @@ -10,6 +10,7 @@ import ( "path/filepath" "strings" "sync" + "syscall" "github.com/docker/docker/pkg/system" "github.com/opencontainers/runc/libcontainer/user" @@ -20,20 +21,29 @@ var ( getentCmd string ) -func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chownExisting bool) error { +func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting bool) error { // make an array containing the original path asked for, plus (for mkAll == true) // all path components leading up to the complete path that don't exist before we MkdirAll // so that we can chown all of them properly at the end. If chownExisting is false, we won't // chown the full directory path if it exists + var paths []string - if _, err := os.Stat(path); err != nil && os.IsNotExist(err) { - paths = []string{path} - } else if err == nil && chownExisting { + + stat, err := system.Stat(path) + if err == nil { + if !stat.IsDir() { + return &os.PathError{Op: "mkdir", Path: path, Err: syscall.ENOTDIR} + } + if !chownExisting { + return nil + } + // short-circuit--we were called with an existing directory and chown was requested - return os.Chown(path, ownerUID, ownerGID) - } else if err == nil { - // nothing to do; directory path fully exists already and chown was NOT requested - return nil + return lazyChown(path, owner.UID, owner.GID, stat) + } + + if os.IsNotExist(err) { + paths = []string{path} } if mkAll { @@ -49,7 +59,7 @@ func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chown paths = append(paths, dirPath) } } - if err := system.MkdirAll(path, mode, ""); err != nil && !os.IsExist(err) { + if err := system.MkdirAll(path, mode, ""); err != nil { return err } } else { @@ -60,7 +70,7 @@ func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chown // even if it existed, we will chown the requested path + any subpaths that // didn't exist when we called MkdirAll for _, pathComponent := range paths { - if err := os.Chown(pathComponent, ownerUID, ownerGID); err != nil { + if err := lazyChown(pathComponent, owner.UID, owner.GID, nil); err != nil { return err } } @@ -69,7 +79,7 @@ func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chown // CanAccess takes a valid (existing) directory and a uid, gid pair and determines // if that uid, gid pair has access (execute bit) to the directory -func CanAccess(path string, pair IDPair) bool { +func CanAccess(path string, pair Identity) bool { statInfo, err := system.Stat(path) if err != nil { return false @@ -202,3 +212,20 @@ func callGetent(args string) (io.Reader, error) { } return bytes.NewReader(out), nil } + +// lazyChown performs a chown only if the uid/gid don't match what's requested +// Normally a Chown is a no-op if uid/gid match, but in some cases this can still cause an error, e.g. if the +// dir is on an NFS share, so don't call chown unless we absolutely must. +func lazyChown(p string, uid, gid int, stat *system.StatT) error { + if stat == nil { + var err error + stat, err = system.Stat(p) + if err != nil { + return err + } + } + if stat.UID() == uint32(uid) && stat.GID() == uint32(gid) { + return nil + } + return os.Chown(p, uid, gid) +} diff --git a/vendor/github.com/docker/docker/pkg/idtools/idtools_windows.go b/vendor/github.com/docker/docker/pkg/idtools/idtools_windows.go index 45d2878e38..4ae38a1b17 100644 --- a/vendor/github.com/docker/docker/pkg/idtools/idtools_windows.go +++ b/vendor/github.com/docker/docker/pkg/idtools/idtools_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package idtools +package idtools // import "github.com/docker/docker/pkg/idtools" import ( "os" @@ -8,10 +6,12 @@ import ( "github.com/docker/docker/pkg/system" ) -// Platforms such as Windows do not support the UID/GID concept. So make this -// just a wrapper around system.MkdirAll. -func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chownExisting bool) error { - if err := system.MkdirAll(path, mode, ""); err != nil && !os.IsExist(err) { +// This is currently a wrapper around MkdirAll, however, since currently +// permissions aren't set through this path, the identity isn't utilized. +// Ownership is handled elsewhere, but in the future could be support here +// too. +func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting bool) error { + if err := system.MkdirAll(path, mode, ""); err != nil { return err } return nil @@ -20,6 +20,6 @@ func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chown // CanAccess takes a valid (existing) directory and a uid, gid pair and determines // if that uid, gid pair has access (execute bit) to the directory // Windows does not require/support this function, so always return true -func CanAccess(path string, pair IDPair) bool { +func CanAccess(path string, identity Identity) bool { return true } diff --git a/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_linux.go b/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_linux.go index 9da7975e2c..6272c5a404 100644 --- a/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_linux.go +++ b/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_linux.go @@ -1,4 +1,4 @@ -package idtools +package idtools // import "github.com/docker/docker/pkg/idtools" import ( "fmt" diff --git a/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go b/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go index d98b354cbd..e7c4d63118 100644 --- a/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go @@ -1,6 +1,6 @@ // +build !linux -package idtools +package idtools // import "github.com/docker/docker/pkg/idtools" import "fmt" diff --git a/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go b/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go index 9703ecbd9d..903ac4501b 100644 --- a/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go +++ b/vendor/github.com/docker/docker/pkg/idtools/utils_unix.go @@ -1,6 +1,6 @@ // +build !windows -package idtools +package idtools // import "github.com/docker/docker/pkg/idtools" import ( "fmt" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/buffer.go b/vendor/github.com/docker/docker/pkg/ioutils/buffer.go index 3d737b3e19..466f79294b 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/buffer.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/buffer.go @@ -1,4 +1,4 @@ -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( "errors" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go b/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go index 72a04f3491..d4bbf3c9dc 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go @@ -1,4 +1,4 @@ -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( "errors" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go b/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go index a56c462651..534d66ac26 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go @@ -1,4 +1,4 @@ -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( "io" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/readers.go b/vendor/github.com/docker/docker/pkg/ioutils/readers.go index 63f3c07f46..1f657bd3dc 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/readers.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/readers.go @@ -1,25 +1,28 @@ -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( + "context" "crypto/sha256" "encoding/hex" "io" - - "golang.org/x/net/context" ) -type readCloserWrapper struct { +// ReadCloserWrapper wraps an io.Reader, and implements an io.ReadCloser +// It calls the given callback function when closed. It should be constructed +// with NewReadCloserWrapper +type ReadCloserWrapper struct { io.Reader closer func() error } -func (r *readCloserWrapper) Close() error { +// Close calls back the passed closer function +func (r *ReadCloserWrapper) Close() error { return r.closer() } // NewReadCloserWrapper returns a new io.ReadCloser. func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser { - return &readCloserWrapper{ + return &ReadCloserWrapper{ Reader: r, closer: closer, } diff --git a/vendor/github.com/docker/docker/pkg/ioutils/temp_unix.go b/vendor/github.com/docker/docker/pkg/ioutils/temp_unix.go index 1539ad21b5..dc894f9131 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/temp_unix.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/temp_unix.go @@ -1,6 +1,6 @@ // +build !windows -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import "io/ioutil" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/temp_windows.go b/vendor/github.com/docker/docker/pkg/ioutils/temp_windows.go index c258e5fdd8..ecaba2e36d 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/temp_windows.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/temp_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( "io/ioutil" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go b/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go index 52a4901ade..91b8d18266 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go @@ -1,4 +1,4 @@ -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import ( "io" diff --git a/vendor/github.com/docker/docker/pkg/ioutils/writers.go b/vendor/github.com/docker/docker/pkg/ioutils/writers.go index ccc7f9c23e..61c679497d 100644 --- a/vendor/github.com/docker/docker/pkg/ioutils/writers.go +++ b/vendor/github.com/docker/docker/pkg/ioutils/writers.go @@ -1,4 +1,4 @@ -package ioutils +package ioutils // import "github.com/docker/docker/pkg/ioutils" import "io" diff --git a/vendor/github.com/docker/docker/pkg/longpath/longpath.go b/vendor/github.com/docker/docker/pkg/longpath/longpath.go index 9b15bfff4c..4177affba2 100644 --- a/vendor/github.com/docker/docker/pkg/longpath/longpath.go +++ b/vendor/github.com/docker/docker/pkg/longpath/longpath.go @@ -2,7 +2,7 @@ // in Windows, which are expected to be prepended with `\\?\` and followed by either // a drive letter, a UNC server\share, or a volume identifier. -package longpath +package longpath // import "github.com/docker/docker/pkg/longpath" import ( "strings" diff --git a/vendor/github.com/docker/docker/pkg/mount/flags.go b/vendor/github.com/docker/docker/pkg/mount/flags.go index 607dbed43a..ffd473311d 100644 --- a/vendor/github.com/docker/docker/pkg/mount/flags.go +++ b/vendor/github.com/docker/docker/pkg/mount/flags.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" import ( "fmt" @@ -135,15 +135,3 @@ func parseOptions(options string) (int, string) { } return flag, strings.Join(data, ",") } - -// ParseTmpfsOptions parse fstab type mount options into flags and data -func ParseTmpfsOptions(options string) (int, string, error) { - flags, data := parseOptions(options) - for _, o := range strings.Split(data, ",") { - opt := strings.SplitN(o, "=", 2) - if !validFlags[opt[0]] { - return 0, "", fmt.Errorf("Invalid tmpfs option %q", opt) - } - } - return flags, data, nil -} diff --git a/vendor/github.com/docker/docker/pkg/mount/flags_freebsd.go b/vendor/github.com/docker/docker/pkg/mount/flags_freebsd.go index 5f76f331b6..ef35ef9059 100644 --- a/vendor/github.com/docker/docker/pkg/mount/flags_freebsd.go +++ b/vendor/github.com/docker/docker/pkg/mount/flags_freebsd.go @@ -1,6 +1,6 @@ // +build freebsd,cgo -package mount +package mount // import "github.com/docker/docker/pkg/mount" /* #include diff --git a/vendor/github.com/docker/docker/pkg/mount/flags_linux.go b/vendor/github.com/docker/docker/pkg/mount/flags_linux.go index 0425d0dd63..a1b199a31a 100644 --- a/vendor/github.com/docker/docker/pkg/mount/flags_linux.go +++ b/vendor/github.com/docker/docker/pkg/mount/flags_linux.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" import ( "golang.org/x/sys/unix" diff --git a/vendor/github.com/docker/docker/pkg/mount/flags_unsupported.go b/vendor/github.com/docker/docker/pkg/mount/flags_unsupported.go index 9ed741e3ff..cc6c475908 100644 --- a/vendor/github.com/docker/docker/pkg/mount/flags_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/mount/flags_unsupported.go @@ -1,6 +1,6 @@ -// +build !linux,!freebsd freebsd,!cgo solaris,!cgo +// +build !linux,!freebsd freebsd,!cgo -package mount +package mount // import "github.com/docker/docker/pkg/mount" // These flags are unsupported. const ( diff --git a/vendor/github.com/docker/docker/pkg/mount/mount.go b/vendor/github.com/docker/docker/pkg/mount/mount.go index c9fdfd6942..4afd63c427 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mount.go +++ b/vendor/github.com/docker/docker/pkg/mount/mount.go @@ -1,30 +1,100 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" import ( "sort" + "strconv" "strings" + + "github.com/sirupsen/logrus" ) -// GetMounts retrieves a list of mounts for the current running process. -func GetMounts() ([]*Info, error) { - return parseMountTable() +// mountError records an error from mount or unmount operation +type mountError struct { + op string + source, target string + flags uintptr + data string + err error +} + +func (e *mountError) Error() string { + out := e.op + " " + + if e.source != "" { + out += e.source + ":" + e.target + } else { + out += e.target + } + + if e.flags != uintptr(0) { + out += ", flags: 0x" + strconv.FormatUint(uint64(e.flags), 16) + } + if e.data != "" { + out += ", data: " + e.data + } + + out += ": " + e.err.Error() + return out +} + +// Cause returns the underlying cause of the error +func (e *mountError) Cause() error { + return e.err +} + +// FilterFunc is a type defining a callback function +// to filter out unwanted entries. It takes a pointer +// to an Info struct (not fully populated, currently +// only Mountpoint is filled in), and returns two booleans: +// - skip: true if the entry should be skipped +// - stop: true if parsing should be stopped after the entry +type FilterFunc func(*Info) (skip, stop bool) + +// PrefixFilter discards all entries whose mount points +// do not start with a prefix specified +func PrefixFilter(prefix string) FilterFunc { + return func(m *Info) (bool, bool) { + skip := !strings.HasPrefix(m.Mountpoint, prefix) + return skip, false + } +} + +// SingleEntryFilter looks for a specific entry +func SingleEntryFilter(mp string) FilterFunc { + return func(m *Info) (bool, bool) { + if m.Mountpoint == mp { + return false, true // don't skip, stop now + } + return true, false // skip, keep going + } +} + +// ParentsFilter returns all entries whose mount points +// can be parents of a path specified, discarding others. +// For example, given `/var/lib/docker/something`, entries +// like `/var/lib/docker`, `/var` and `/` are returned. +func ParentsFilter(path string) FilterFunc { + return func(m *Info) (bool, bool) { + skip := !strings.HasPrefix(path, m.Mountpoint) + return skip, false + } +} + +// GetMounts retrieves a list of mounts for the current running process, +// with an optional filter applied (use nil for no filter). +func GetMounts(f FilterFunc) ([]*Info, error) { + return parseMountTable(f) } // Mounted determines if a specified mountpoint has been mounted. -// On Linux it looks at /proc/self/mountinfo and on Solaris at mnttab. +// On Linux it looks at /proc/self/mountinfo. func Mounted(mountpoint string) (bool, error) { - entries, err := parseMountTable() + entries, err := GetMounts(SingleEntryFilter(mountpoint)) if err != nil { return false, err } - // Search the table for the mountpoint - for _, e := range entries { - if e.Mountpoint == mountpoint { - return true, nil - } - } - return false, nil + return len(entries) > 0, nil } // Mount will mount filesystem according to the specified configuration, on the @@ -53,34 +123,37 @@ func ForceMount(device, target, mType, options string) error { // Unmount lazily unmounts a filesystem on supported platforms, otherwise // does a normal unmount. func Unmount(target string) error { - if mounted, err := Mounted(target); err != nil || !mounted { - return err - } return unmount(target, mntDetach) } // RecursiveUnmount unmounts the target and all mounts underneath, starting with // the deepsest mount first. func RecursiveUnmount(target string) error { - mounts, err := GetMounts() + mounts, err := parseMountTable(PrefixFilter(target)) if err != nil { return err } // Make the deepest mount be first - sort.Sort(sort.Reverse(byMountpoint(mounts))) + sort.Slice(mounts, func(i, j int) bool { + return len(mounts[i].Mountpoint) > len(mounts[j].Mountpoint) + }) for i, m := range mounts { - if !strings.HasPrefix(m.Mountpoint, target) { - continue - } - if err := Unmount(m.Mountpoint); err != nil && i == len(mounts)-1 { - if mounted, err := Mounted(m.Mountpoint); err != nil || mounted { - return err + logrus.Debugf("Trying to unmount %s", m.Mountpoint) + err = unmount(m.Mountpoint, mntDetach) + if err != nil { + if i == len(mounts)-1 { // last mount + if mounted, e := Mounted(m.Mountpoint); e != nil || mounted { + return err + } + } else { + // This is some submount, we can ignore this error for now, the final unmount will fail if this is a real problem + logrus.WithError(err).Warnf("Failed to unmount submount %s", m.Mountpoint) } - // Ignore errors for submounts and continue trying to unmount others - // The final unmount should fail if there ane any submounts remaining } + + logrus.Debugf("Unmounted %s", m.Mountpoint) } return nil } diff --git a/vendor/github.com/docker/docker/pkg/mount/mounter_freebsd.go b/vendor/github.com/docker/docker/pkg/mount/mounter_freebsd.go index 814896cc9e..09ad360608 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mounter_freebsd.go +++ b/vendor/github.com/docker/docker/pkg/mount/mounter_freebsd.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" /* #include @@ -11,11 +11,9 @@ package mount import "C" import ( - "fmt" "strings" + "syscall" "unsafe" - - "golang.org/x/sys/unix" ) func allocateIOVecs(options []string) []C.struct_iovec { @@ -49,12 +47,13 @@ func mount(device, target, mType string, flag uintptr, data string) error { } if errno := C.nmount(&rawOptions[0], C.uint(len(options)), C.int(flag)); errno != 0 { - reason := C.GoString(C.strerror(*C.__error())) - return fmt.Errorf("Failed to call nmount: %s", reason) + return &mountError{ + op: "mount", + source: device, + target: target, + flags: flag, + err: syscall.Errno(errno), + } } return nil } - -func unmount(target string, flag int) error { - return unix.Unmount(target, flag) -} diff --git a/vendor/github.com/docker/docker/pkg/mount/mounter_linux.go b/vendor/github.com/docker/docker/pkg/mount/mounter_linux.go index 39c36d472a..a0a1ad2364 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mounter_linux.go +++ b/vendor/github.com/docker/docker/pkg/mount/mounter_linux.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" import ( "golang.org/x/sys/unix" @@ -33,25 +33,41 @@ func mount(device, target, mType string, flags uintptr, data string) error { // Initial call applying all non-propagation flags for mount // or remount with changed data if err := unix.Mount(device, target, mType, oflags, data); err != nil { - return err + return &mountError{ + op: "mount", + source: device, + target: target, + flags: oflags, + data: data, + err: err, + } } } if flags&ptypes != 0 { // Change the propagation type. if err := unix.Mount("", target, "", flags&pflags, ""); err != nil { - return err + return &mountError{ + op: "remount", + target: target, + flags: flags & pflags, + err: err, + } } } if oflags&broflags == broflags { // Remount the bind to apply read only. - return unix.Mount("", target, "", oflags|unix.MS_REMOUNT, "") + if err := unix.Mount("", target, "", oflags|unix.MS_REMOUNT, ""); err != nil { + return &mountError{ + op: "remount-ro", + target: target, + flags: oflags | unix.MS_REMOUNT, + err: err, + } + + } } return nil } - -func unmount(target string, flag int) error { - return unix.Unmount(target, flag) -} diff --git a/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go b/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go deleted file mode 100644 index 48b86771e7..0000000000 --- a/vendor/github.com/docker/docker/pkg/mount/mounter_solaris.go +++ /dev/null @@ -1,34 +0,0 @@ -// +build solaris,cgo - -package mount - -import ( - "unsafe" - - "golang.org/x/sys/unix" -) - -// #include -// #include -// #include -// int Mount(const char *spec, const char *dir, int mflag, -// char *fstype, char *dataptr, int datalen, char *optptr, int optlen) { -// return mount(spec, dir, mflag, fstype, dataptr, datalen, optptr, optlen); -// } -import "C" - -func mount(device, target, mType string, flag uintptr, data string) error { - spec := C.CString(device) - dir := C.CString(target) - fstype := C.CString(mType) - _, err := C.Mount(spec, dir, C.int(flag), fstype, nil, 0, nil, 0) - C.free(unsafe.Pointer(spec)) - C.free(unsafe.Pointer(dir)) - C.free(unsafe.Pointer(fstype)) - return err -} - -func unmount(target string, flag int) error { - err := unix.Unmount(target, flag) - return err -} diff --git a/vendor/github.com/docker/docker/pkg/mount/mounter_unsupported.go b/vendor/github.com/docker/docker/pkg/mount/mounter_unsupported.go index a2a3bb457f..c3e5aec274 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mounter_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/mount/mounter_unsupported.go @@ -1,11 +1,7 @@ -// +build !linux,!freebsd,!solaris freebsd,!cgo solaris,!cgo +// +build !linux,!freebsd freebsd,!cgo -package mount +package mount // import "github.com/docker/docker/pkg/mount" func mount(device, target, mType string, flag uintptr, data string) error { panic("Not implemented") } - -func unmount(target string, flag int) error { - panic("Not implemented") -} diff --git a/vendor/github.com/docker/docker/pkg/mount/mountinfo.go b/vendor/github.com/docker/docker/pkg/mount/mountinfo.go index ff4cc1d86b..ecd03fc022 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mountinfo.go +++ b/vendor/github.com/docker/docker/pkg/mount/mountinfo.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" // Info reveals information about a particular mounted filesystem. This // struct is populated from the content in the /proc//mountinfo file. @@ -38,17 +38,3 @@ type Info struct { // VfsOpts represents per super block options. VfsOpts string } - -type byMountpoint []*Info - -func (by byMountpoint) Len() int { - return len(by) -} - -func (by byMountpoint) Less(i, j int) bool { - return by[i].Mountpoint < by[j].Mountpoint -} - -func (by byMountpoint) Swap(i, j int) { - by[i], by[j] = by[j], by[i] -} diff --git a/vendor/github.com/docker/docker/pkg/mount/mountinfo_freebsd.go b/vendor/github.com/docker/docker/pkg/mount/mountinfo_freebsd.go index 4f32edcd90..36c89dc1a2 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mountinfo_freebsd.go +++ b/vendor/github.com/docker/docker/pkg/mount/mountinfo_freebsd.go @@ -1,4 +1,4 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" /* #include @@ -15,7 +15,7 @@ import ( // Parse /proc/self/mountinfo because comparing Dev and ino does not work from // bind mounts. -func parseMountTable() ([]*Info, error) { +func parseMountTable(filter FilterFunc) ([]*Info, error) { var rawEntries *C.struct_statfs count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT)) @@ -32,10 +32,24 @@ func parseMountTable() ([]*Info, error) { var out []*Info for _, entry := range entries { var mountinfo Info + var skip, stop bool mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0]) + + if filter != nil { + // filter out entries we're not interested in + skip, stop = filter(p) + if skip { + continue + } + } + mountinfo.Source = C.GoString(&entry.f_mntfromname[0]) mountinfo.Fstype = C.GoString(&entry.f_fstypename[0]) + out = append(out, &mountinfo) + if stop { + break + } } return out, nil } diff --git a/vendor/github.com/docker/docker/pkg/mount/mountinfo_linux.go b/vendor/github.com/docker/docker/pkg/mount/mountinfo_linux.go index be69fee1d7..c1dba01fc3 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mountinfo_linux.go +++ b/vendor/github.com/docker/docker/pkg/mount/mountinfo_linux.go @@ -1,86 +1,123 @@ -// +build linux - -package mount +package mount // import "github.com/docker/docker/pkg/mount" import ( "bufio" "fmt" "io" "os" + "strconv" "strings" ) -const ( - /* 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue - (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) +func parseInfoFile(r io.Reader, filter FilterFunc) ([]*Info, error) { + s := bufio.NewScanner(r) + out := []*Info{} + for s.Scan() { + if err := s.Err(); err != nil { + return nil, err + } + /* + 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue + (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) - (1) mount ID: unique identifier of the mount (may be reused after umount) - (2) parent ID: ID of parent (or of self for the top of the mount tree) - (3) major:minor: value of st_dev for files on filesystem - (4) root: root of the mount within the filesystem - (5) mount point: mount point relative to the process's root - (6) mount options: per mount options - (7) optional fields: zero or more fields of the form "tag[:value]" - (8) separator: marks the end of the optional fields - (9) filesystem type: name of filesystem of the form "type[.subtype]" - (10) mount source: filesystem specific information or "none" - (11) super options: per super block options*/ - mountinfoFormat = "%d %d %d:%d %s %s %s %s" -) + (1) mount ID: unique identifier of the mount (may be reused after umount) + (2) parent ID: ID of parent (or of self for the top of the mount tree) + (3) major:minor: value of st_dev for files on filesystem + (4) root: root of the mount within the filesystem + (5) mount point: mount point relative to the process's root + (6) mount options: per mount options + (7) optional fields: zero or more fields of the form "tag[:value]" + (8) separator: marks the end of the optional fields + (9) filesystem type: name of filesystem of the form "type[.subtype]" + (10) mount source: filesystem specific information or "none" + (11) super options: per super block options + */ -// Parse /proc/self/mountinfo because comparing Dev and ino does not work from -// bind mounts -func parseMountTable() ([]*Info, error) { - f, err := os.Open("/proc/self/mountinfo") - if err != nil { - return nil, err - } - defer f.Close() + text := s.Text() + fields := strings.Split(text, " ") + numFields := len(fields) + if numFields < 10 { + // should be at least 10 fields + return nil, fmt.Errorf("Parsing '%s' failed: not enough fields (%d)", text, numFields) + } - return parseInfoFile(f) -} + p := &Info{} + // ignore any numbers parsing errors, as there should not be any + p.ID, _ = strconv.Atoi(fields[0]) + p.Parent, _ = strconv.Atoi(fields[1]) + mm := strings.Split(fields[2], ":") + if len(mm) != 2 { + return nil, fmt.Errorf("Parsing '%s' failed: unexpected minor:major pair %s", text, mm) + } + p.Major, _ = strconv.Atoi(mm[0]) + p.Minor, _ = strconv.Atoi(mm[1]) -func parseInfoFile(r io.Reader) ([]*Info, error) { - var ( - s = bufio.NewScanner(r) - out = []*Info{} - ) + p.Root = fields[3] + p.Mountpoint = fields[4] + p.Opts = fields[5] - for s.Scan() { - if err := s.Err(); err != nil { - return nil, err + var skip, stop bool + if filter != nil { + // filter out entries we're not interested in + skip, stop = filter(p) + if skip { + continue + } } - var ( - p = &Info{} - text = s.Text() - optionalFields string - ) - - if _, err := fmt.Sscanf(text, mountinfoFormat, - &p.ID, &p.Parent, &p.Major, &p.Minor, - &p.Root, &p.Mountpoint, &p.Opts, &optionalFields); err != nil { - return nil, fmt.Errorf("Scanning '%s' failed: %s", text, err) + // one or more optional fields, when a separator (-) + i := 6 + for ; i < numFields && fields[i] != "-"; i++ { + switch i { + case 6: + p.Optional = fields[6] + default: + /* NOTE there might be more optional fields before the such as + fields[7]...fields[N] (where N < sepIndex), although + as of Linux kernel 4.15 the only known ones are + mount propagation flags in fields[6]. The correct + behavior is to ignore any unknown optional fields. + */ + break + } } - // Safe as mountinfo encodes mountpoints with spaces as \040. - index := strings.Index(text, " - ") - postSeparatorFields := strings.Fields(text[index+3:]) - if len(postSeparatorFields) < 3 { - return nil, fmt.Errorf("Error found less than 3 fields post '-' in %q", text) + if i == numFields { + return nil, fmt.Errorf("Parsing '%s' failed: missing separator ('-')", text) } - if optionalFields != "-" { - p.Optional = optionalFields + // There should be 3 fields after the separator... + if i+4 > numFields { + return nil, fmt.Errorf("Parsing '%s' failed: not enough fields after a separator", text) } + // ... but in Linux <= 3.9 mounting a cifs with spaces in a share name + // (like "//serv/My Documents") _may_ end up having a space in the last field + // of mountinfo (like "unc=//serv/My Documents"). Since kernel 3.10-rc1, cifs + // option unc= is ignored, so a space should not appear. In here we ignore + // those "extra" fields caused by extra spaces. + p.Fstype = fields[i+1] + p.Source = fields[i+2] + p.VfsOpts = fields[i+3] - p.Fstype = postSeparatorFields[0] - p.Source = postSeparatorFields[1] - p.VfsOpts = strings.Join(postSeparatorFields[2:], " ") out = append(out, p) + if stop { + break + } } return out, nil } +// Parse /proc/self/mountinfo because comparing Dev and ino does not work from +// bind mounts +func parseMountTable(filter FilterFunc) ([]*Info, error) { + f, err := os.Open("/proc/self/mountinfo") + if err != nil { + return nil, err + } + defer f.Close() + + return parseInfoFile(f, filter) +} + // PidMountInfo collects the mounts for a specific process ID. If the process // ID is unknown, it is better to use `GetMounts` which will inspect // "/proc/self/mountinfo" instead. @@ -91,5 +128,5 @@ func PidMountInfo(pid int) ([]*Info, error) { } defer f.Close() - return parseInfoFile(f) + return parseInfoFile(f, nil) } diff --git a/vendor/github.com/docker/docker/pkg/mount/mountinfo_solaris.go b/vendor/github.com/docker/docker/pkg/mount/mountinfo_solaris.go deleted file mode 100644 index 069ed8f2de..0000000000 --- a/vendor/github.com/docker/docker/pkg/mount/mountinfo_solaris.go +++ /dev/null @@ -1,44 +0,0 @@ -// +build solaris,cgo - -package mount - -/* -#include -#include -#include -*/ -import "C" - -import ( - "fmt" - "unsafe" -) - -func parseMountTable() ([]*Info, error) { - path := C.CString(C.MNTTAB) - defer C.free(unsafe.Pointer(path)) - mode := C.CString("r") - defer C.free(unsafe.Pointer(mode)) - - mnttab := C.fopen(path, mode) - if mnttab == nil { - return nil, fmt.Errorf("Failed to open %s", C.MNTTAB) - } - - var out []*Info - var mp C.struct_mnttab - - ret := C.getmntent(mnttab, &mp) - for ret == 0 { - var mountinfo Info - mountinfo.Mountpoint = C.GoString(mp.mnt_mountp) - mountinfo.Source = C.GoString(mp.mnt_special) - mountinfo.Fstype = C.GoString(mp.mnt_fstype) - mountinfo.Opts = C.GoString(mp.mnt_mntopts) - out = append(out, &mountinfo) - ret = C.getmntent(mnttab, &mp) - } - - C.fclose(mnttab) - return out, nil -} diff --git a/vendor/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go b/vendor/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go index 7fbcf19214..fd16d3ed69 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go @@ -1,12 +1,12 @@ -// +build !windows,!linux,!freebsd,!solaris freebsd,!cgo solaris,!cgo +// +build !windows,!linux,!freebsd freebsd,!cgo -package mount +package mount // import "github.com/docker/docker/pkg/mount" import ( "fmt" "runtime" ) -func parseMountTable() ([]*Info, error) { +func parseMountTable(f FilterFunc) ([]*Info, error) { return nil, fmt.Errorf("mount.parseMountTable is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) } diff --git a/vendor/github.com/docker/docker/pkg/mount/mountinfo_windows.go b/vendor/github.com/docker/docker/pkg/mount/mountinfo_windows.go index dab8a37ed0..27e0f6976e 100644 --- a/vendor/github.com/docker/docker/pkg/mount/mountinfo_windows.go +++ b/vendor/github.com/docker/docker/pkg/mount/mountinfo_windows.go @@ -1,6 +1,6 @@ -package mount +package mount // import "github.com/docker/docker/pkg/mount" -func parseMountTable() ([]*Info, error) { +func parseMountTable(f FilterFunc) ([]*Info, error) { // Do NOT return an error! return nil, nil } diff --git a/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_linux.go b/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_linux.go index 8ceec84bc6..8a100f0bc8 100644 --- a/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_linux.go +++ b/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_linux.go @@ -1,6 +1,4 @@ -// +build linux - -package mount +package mount // import "github.com/docker/docker/pkg/mount" // MakeShared ensures a mounted filesystem has the SHARED mount option enabled. // See the supported options in flags.go for further reference. @@ -50,18 +48,22 @@ func MakeRUnbindable(mountPoint string) error { return ensureMountedAs(mountPoint, "runbindable") } -func ensureMountedAs(mountPoint, options string) error { - mounted, err := Mounted(mountPoint) +// MakeMount ensures that the file or directory given is a mount point, +// bind mounting it to itself it case it is not. +func MakeMount(mnt string) error { + mounted, err := Mounted(mnt) if err != nil { return err } - - if !mounted { - if err := Mount(mountPoint, mountPoint, "none", "bind,rw"); err != nil { - return err - } + if mounted { + return nil } - if _, err = Mounted(mountPoint); err != nil { + + return Mount(mnt, mnt, "none", "bind") +} + +func ensureMountedAs(mountPoint, options string) error { + if err := MakeMount(mountPoint); err != nil { return err } diff --git a/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_solaris.go b/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_solaris.go deleted file mode 100644 index 09f6b03cbc..0000000000 --- a/vendor/github.com/docker/docker/pkg/mount/sharedsubtree_solaris.go +++ /dev/null @@ -1,58 +0,0 @@ -// +build solaris - -package mount - -// MakeShared ensures a mounted filesystem has the SHARED mount option enabled. -// See the supported options in flags.go for further reference. -func MakeShared(mountPoint string) error { - return ensureMountedAs(mountPoint, "shared") -} - -// MakeRShared ensures a mounted filesystem has the RSHARED mount option enabled. -// See the supported options in flags.go for further reference. -func MakeRShared(mountPoint string) error { - return ensureMountedAs(mountPoint, "rshared") -} - -// MakePrivate ensures a mounted filesystem has the PRIVATE mount option enabled. -// See the supported options in flags.go for further reference. -func MakePrivate(mountPoint string) error { - return ensureMountedAs(mountPoint, "private") -} - -// MakeRPrivate ensures a mounted filesystem has the RPRIVATE mount option -// enabled. See the supported options in flags.go for further reference. -func MakeRPrivate(mountPoint string) error { - return ensureMountedAs(mountPoint, "rprivate") -} - -// MakeSlave ensures a mounted filesystem has the SLAVE mount option enabled. -// See the supported options in flags.go for further reference. -func MakeSlave(mountPoint string) error { - return ensureMountedAs(mountPoint, "slave") -} - -// MakeRSlave ensures a mounted filesystem has the RSLAVE mount option enabled. -// See the supported options in flags.go for further reference. -func MakeRSlave(mountPoint string) error { - return ensureMountedAs(mountPoint, "rslave") -} - -// MakeUnbindable ensures a mounted filesystem has the UNBINDABLE mount option -// enabled. See the supported options in flags.go for further reference. -func MakeUnbindable(mountPoint string) error { - return ensureMountedAs(mountPoint, "unbindable") -} - -// MakeRUnbindable ensures a mounted filesystem has the RUNBINDABLE mount -// option enabled. See the supported options in flags.go for further reference. -func MakeRUnbindable(mountPoint string) error { - return ensureMountedAs(mountPoint, "runbindable") -} - -func ensureMountedAs(mountPoint, options string) error { - // TODO: Solaris does not support bind mounts. - // Evaluate lofs and also look at the relevant - // mount flags to be supported. - return nil -} diff --git a/vendor/github.com/docker/docker/pkg/mount/unmount_unix.go b/vendor/github.com/docker/docker/pkg/mount/unmount_unix.go new file mode 100644 index 0000000000..4be4276851 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/mount/unmount_unix.go @@ -0,0 +1,22 @@ +// +build !windows + +package mount // import "github.com/docker/docker/pkg/mount" + +import "golang.org/x/sys/unix" + +func unmount(target string, flags int) error { + err := unix.Unmount(target, flags) + if err == nil || err == unix.EINVAL { + // Ignore "not mounted" error here. Note the same error + // can be returned if flags are invalid, so this code + // assumes that the flags value is always correct. + return nil + } + + return &mountError{ + op: "umount", + target: target, + flags: uintptr(flags), + err: err, + } +} diff --git a/vendor/github.com/docker/docker/pkg/mount/unmount_unsupported.go b/vendor/github.com/docker/docker/pkg/mount/unmount_unsupported.go new file mode 100644 index 0000000000..a88ad35774 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/mount/unmount_unsupported.go @@ -0,0 +1,7 @@ +// +build windows + +package mount // import "github.com/docker/docker/pkg/mount" + +func unmount(target string, flag int) error { + panic("Not implemented") +} diff --git a/vendor/github.com/docker/docker/pkg/pools/pools.go b/vendor/github.com/docker/docker/pkg/pools/pools.go index 6a111a3ba7..46339c282f 100644 --- a/vendor/github.com/docker/docker/pkg/pools/pools.go +++ b/vendor/github.com/docker/docker/pkg/pools/pools.go @@ -7,7 +7,7 @@ // // Utility functions which operate on pools should be added to this // package to allow them to be reused. -package pools +package pools // import "github.com/docker/docker/pkg/pools" import ( "bufio" diff --git a/vendor/github.com/docker/docker/pkg/signal/signal.go b/vendor/github.com/docker/docker/pkg/signal/signal.go index 68bb77cf58..88ef7b5ea2 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal.go @@ -1,6 +1,6 @@ // Package signal provides helper functions for dealing with signals across // various operating systems. -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "fmt" @@ -13,7 +13,7 @@ import ( // CatchAll catches all signals and relays them to the specified channel. func CatchAll(sigc chan os.Signal) { - handledSigs := []os.Signal{} + var handledSigs []os.Signal for _, s := range SignalMap { handledSigs = append(handledSigs, s) } diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go b/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go index 946de87e94..ee5501e3d9 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_darwin.go @@ -1,4 +1,4 @@ -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go b/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go index 6b9569bb75..764f90e264 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_freebsd.go @@ -1,4 +1,4 @@ -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_linux.go b/vendor/github.com/docker/docker/pkg/signal/signal_linux.go index 66c85c8e08..4013bded13 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_linux.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_linux.go @@ -1,4 +1,6 @@ -package signal +// +build !mips,!mipsle,!mips64,!mips64le + +package signal // import "github.com/docker/docker/pkg/signal" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go b/vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go new file mode 100644 index 0000000000..4c79891216 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/signal/signal_linux_mipsx.go @@ -0,0 +1,84 @@ +// +build linux +// +build mips mipsle mips64 mips64le + +package signal // import "github.com/docker/docker/pkg/signal" + +import ( + "syscall" + + "golang.org/x/sys/unix" +) + +const ( + sigrtmin = 34 + sigrtmax = 127 +) + +// SignalMap is a map of Linux signals. +var SignalMap = map[string]syscall.Signal{ + "ABRT": unix.SIGABRT, + "ALRM": unix.SIGALRM, + "BUS": unix.SIGBUS, + "CHLD": unix.SIGCHLD, + "CLD": unix.SIGCLD, + "CONT": unix.SIGCONT, + "FPE": unix.SIGFPE, + "HUP": unix.SIGHUP, + "ILL": unix.SIGILL, + "INT": unix.SIGINT, + "IO": unix.SIGIO, + "IOT": unix.SIGIOT, + "KILL": unix.SIGKILL, + "PIPE": unix.SIGPIPE, + "POLL": unix.SIGPOLL, + "PROF": unix.SIGPROF, + "PWR": unix.SIGPWR, + "QUIT": unix.SIGQUIT, + "SEGV": unix.SIGSEGV, + "SIGEMT": unix.SIGEMT, + "STOP": unix.SIGSTOP, + "SYS": unix.SIGSYS, + "TERM": unix.SIGTERM, + "TRAP": unix.SIGTRAP, + "TSTP": unix.SIGTSTP, + "TTIN": unix.SIGTTIN, + "TTOU": unix.SIGTTOU, + "URG": unix.SIGURG, + "USR1": unix.SIGUSR1, + "USR2": unix.SIGUSR2, + "VTALRM": unix.SIGVTALRM, + "WINCH": unix.SIGWINCH, + "XCPU": unix.SIGXCPU, + "XFSZ": unix.SIGXFSZ, + "RTMIN": sigrtmin, + "RTMIN+1": sigrtmin + 1, + "RTMIN+2": sigrtmin + 2, + "RTMIN+3": sigrtmin + 3, + "RTMIN+4": sigrtmin + 4, + "RTMIN+5": sigrtmin + 5, + "RTMIN+6": sigrtmin + 6, + "RTMIN+7": sigrtmin + 7, + "RTMIN+8": sigrtmin + 8, + "RTMIN+9": sigrtmin + 9, + "RTMIN+10": sigrtmin + 10, + "RTMIN+11": sigrtmin + 11, + "RTMIN+12": sigrtmin + 12, + "RTMIN+13": sigrtmin + 13, + "RTMIN+14": sigrtmin + 14, + "RTMIN+15": sigrtmin + 15, + "RTMAX-14": sigrtmax - 14, + "RTMAX-13": sigrtmax - 13, + "RTMAX-12": sigrtmax - 12, + "RTMAX-11": sigrtmax - 11, + "RTMAX-10": sigrtmax - 10, + "RTMAX-9": sigrtmax - 9, + "RTMAX-8": sigrtmax - 8, + "RTMAX-7": sigrtmax - 7, + "RTMAX-6": sigrtmax - 6, + "RTMAX-5": sigrtmax - 5, + "RTMAX-4": sigrtmax - 4, + "RTMAX-3": sigrtmax - 3, + "RTMAX-2": sigrtmax - 2, + "RTMAX-1": sigrtmax - 1, + "RTMAX": sigrtmax, +} diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_solaris.go b/vendor/github.com/docker/docker/pkg/signal/signal_solaris.go deleted file mode 100644 index 89576b9e3b..0000000000 --- a/vendor/github.com/docker/docker/pkg/signal/signal_solaris.go +++ /dev/null @@ -1,42 +0,0 @@ -package signal - -import ( - "syscall" -) - -// SignalMap is a map of Solaris signals. -// SIGINFO and SIGTHR not defined for Solaris -var SignalMap = map[string]syscall.Signal{ - "ABRT": syscall.SIGABRT, - "ALRM": syscall.SIGALRM, - "BUF": syscall.SIGBUS, - "CHLD": syscall.SIGCHLD, - "CONT": syscall.SIGCONT, - "EMT": syscall.SIGEMT, - "FPE": syscall.SIGFPE, - "HUP": syscall.SIGHUP, - "ILL": syscall.SIGILL, - "INT": syscall.SIGINT, - "IO": syscall.SIGIO, - "IOT": syscall.SIGIOT, - "KILL": syscall.SIGKILL, - "LWP": syscall.SIGLWP, - "PIPE": syscall.SIGPIPE, - "PROF": syscall.SIGPROF, - "QUIT": syscall.SIGQUIT, - "SEGV": syscall.SIGSEGV, - "STOP": syscall.SIGSTOP, - "SYS": syscall.SIGSYS, - "TERM": syscall.SIGTERM, - "TRAP": syscall.SIGTRAP, - "TSTP": syscall.SIGTSTP, - "TTIN": syscall.SIGTTIN, - "TTOU": syscall.SIGTTOU, - "URG": syscall.SIGURG, - "USR1": syscall.SIGUSR1, - "USR2": syscall.SIGUSR2, - "VTALRM": syscall.SIGVTALRM, - "WINCH": syscall.SIGWINCH, - "XCPU": syscall.SIGXCPU, - "XFSZ": syscall.SIGXFSZ, -} diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_unix.go b/vendor/github.com/docker/docker/pkg/signal/signal_unix.go index 5d058fd56b..a2aa4248fa 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_unix.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_unix.go @@ -1,6 +1,6 @@ // +build !windows -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go b/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go index c592d37dfe..1fd25a83c6 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_unsupported.go @@ -1,6 +1,6 @@ -// +build !linux,!darwin,!freebsd,!windows,!solaris +// +build !linux,!darwin,!freebsd,!windows -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/signal/signal_windows.go b/vendor/github.com/docker/docker/pkg/signal/signal_windows.go index 440f2700e2..65752f24aa 100644 --- a/vendor/github.com/docker/docker/pkg/signal/signal_windows.go +++ b/vendor/github.com/docker/docker/pkg/signal/signal_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/signal/trap.go b/vendor/github.com/docker/docker/pkg/signal/trap.go index 2884dfee32..2a6e69fb50 100644 --- a/vendor/github.com/docker/docker/pkg/signal/trap.go +++ b/vendor/github.com/docker/docker/pkg/signal/trap.go @@ -1,4 +1,4 @@ -package signal +package signal // import "github.com/docker/docker/pkg/signal" import ( "fmt" diff --git a/vendor/github.com/docker/docker/pkg/stdcopy/stdcopy.go b/vendor/github.com/docker/docker/pkg/stdcopy/stdcopy.go index a018a203f3..8f6e0a737a 100644 --- a/vendor/github.com/docker/docker/pkg/stdcopy/stdcopy.go +++ b/vendor/github.com/docker/docker/pkg/stdcopy/stdcopy.go @@ -1,4 +1,4 @@ -package stdcopy +package stdcopy // import "github.com/docker/docker/pkg/stdcopy" import ( "bytes" @@ -21,7 +21,7 @@ const ( // Stderr represents standard error steam type. Stderr // Systemerr represents errors originating from the system that make it - // into the the multiplexed stream. + // into the multiplexed stream. Systemerr stdWriterPrefixLen = 8 diff --git a/vendor/github.com/docker/docker/pkg/system/chtimes.go b/vendor/github.com/docker/docker/pkg/system/chtimes.go index 056d19954d..c26a4e24b6 100644 --- a/vendor/github.com/docker/docker/pkg/system/chtimes.go +++ b/vendor/github.com/docker/docker/pkg/system/chtimes.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "os" @@ -27,9 +27,5 @@ func Chtimes(name string, atime time.Time, mtime time.Time) error { } // Take platform specific action for setting create time. - if err := setCTime(name, mtime); err != nil { - return err - } - - return nil + return setCTime(name, mtime) } diff --git a/vendor/github.com/docker/docker/pkg/system/chtimes_unix.go b/vendor/github.com/docker/docker/pkg/system/chtimes_unix.go index 09d58bcbfd..259138a45b 100644 --- a/vendor/github.com/docker/docker/pkg/system/chtimes_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/chtimes_unix.go @@ -1,6 +1,6 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" import ( "time" diff --git a/vendor/github.com/docker/docker/pkg/system/chtimes_windows.go b/vendor/github.com/docker/docker/pkg/system/chtimes_windows.go index 45428c141c..d3a115ff42 100644 --- a/vendor/github.com/docker/docker/pkg/system/chtimes_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/chtimes_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package system +package system // import "github.com/docker/docker/pkg/system" import ( "time" diff --git a/vendor/github.com/docker/docker/pkg/system/errors.go b/vendor/github.com/docker/docker/pkg/system/errors.go index 288318985e..2573d71622 100644 --- a/vendor/github.com/docker/docker/pkg/system/errors.go +++ b/vendor/github.com/docker/docker/pkg/system/errors.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "errors" @@ -7,4 +7,7 @@ import ( var ( // ErrNotSupportedPlatform means the platform is not supported. ErrNotSupportedPlatform = errors.New("platform and architecture is not supported") + + // ErrNotSupportedOperatingSystem means the operating system is not supported. + ErrNotSupportedOperatingSystem = errors.New("operating system is not supported") ) diff --git a/vendor/github.com/docker/docker/pkg/system/exitcode.go b/vendor/github.com/docker/docker/pkg/system/exitcode.go index a5e5616c4f..4ba8fe35bf 100644 --- a/vendor/github.com/docker/docker/pkg/system/exitcode.go +++ b/vendor/github.com/docker/docker/pkg/system/exitcode.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "fmt" diff --git a/vendor/github.com/docker/docker/pkg/system/filesys.go b/vendor/github.com/docker/docker/pkg/system/filesys.go index 102565f760..adeb163052 100644 --- a/vendor/github.com/docker/docker/pkg/system/filesys.go +++ b/vendor/github.com/docker/docker/pkg/system/filesys.go @@ -1,6 +1,6 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" import ( "io/ioutil" diff --git a/vendor/github.com/docker/docker/pkg/system/filesys_windows.go b/vendor/github.com/docker/docker/pkg/system/filesys_windows.go index a61b53d0ba..a1f6013f13 100644 --- a/vendor/github.com/docker/docker/pkg/system/filesys_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/filesys_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package system +package system // import "github.com/docker/docker/pkg/system" import ( "os" diff --git a/vendor/github.com/docker/docker/pkg/system/init.go b/vendor/github.com/docker/docker/pkg/system/init.go index 17935088de..a17597aaba 100644 --- a/vendor/github.com/docker/docker/pkg/system/init.go +++ b/vendor/github.com/docker/docker/pkg/system/init.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/init_unix.go b/vendor/github.com/docker/docker/pkg/system/init_unix.go index a219895e6d..4996a67c12 100644 --- a/vendor/github.com/docker/docker/pkg/system/init_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/init_unix.go @@ -1,6 +1,6 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" // InitLCOW does nothing since LCOW is a windows only feature func InitLCOW(experimental bool) { diff --git a/vendor/github.com/docker/docker/pkg/system/init_windows.go b/vendor/github.com/docker/docker/pkg/system/init_windows.go index 75f8f2c061..4910ff69d6 100644 --- a/vendor/github.com/docker/docker/pkg/system/init_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/init_windows.go @@ -1,17 +1,12 @@ -package system - -import "os" +package system // import "github.com/docker/docker/pkg/system" // lcowSupported determines if Linux Containers on Windows are supported. var lcowSupported = false // InitLCOW sets whether LCOW is supported or not -// TODO @jhowardmsft. -// 1. Replace with RS3 RTM build number. -// 2. Remove the getenv check when image-store is coalesced as shouldn't be needed anymore. func InitLCOW(experimental bool) { v := GetOSVersion() - if experimental && v.Build > 16270 && os.Getenv("LCOW_SUPPORTED") != "" { + if experimental && v.Build >= 16299 { lcowSupported = true } } diff --git a/vendor/github.com/docker/docker/pkg/system/lcow.go b/vendor/github.com/docker/docker/pkg/system/lcow.go index b88c11e316..5be3e2182b 100644 --- a/vendor/github.com/docker/docker/pkg/system/lcow.go +++ b/vendor/github.com/docker/docker/pkg/system/lcow.go @@ -1,58 +1,32 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( - "fmt" "runtime" "strings" specs "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" ) -// ValidatePlatform determines if a platform structure is valid. -// TODO This is a temporary function - can be replaced by parsing from -// https://github.com/containerd/containerd/pull/1403/files at a later date. -// @jhowardmsft -func ValidatePlatform(platform *specs.Platform) error { - platform.Architecture = strings.ToLower(platform.Architecture) - platform.OS = strings.ToLower(platform.OS) - // Based on https://github.com/moby/moby/pull/34642#issuecomment-330375350, do - // not support anything except operating system. - if platform.Architecture != "" { - return fmt.Errorf("invalid platform architecture %q", platform.Architecture) - } - if platform.OS != "" { - if !(platform.OS == runtime.GOOS || (LCOWSupported() && platform.OS == "linux")) { - return fmt.Errorf("invalid platform os %q", platform.OS) - } +// IsOSSupported determines if an operating system is supported by the host +func IsOSSupported(os string) bool { + if strings.EqualFold(runtime.GOOS, os) { + return true } - if len(platform.OSFeatures) != 0 { - return fmt.Errorf("invalid platform osfeatures %q", platform.OSFeatures) + if LCOWSupported() && strings.EqualFold(os, "linux") { + return true } - if platform.OSVersion != "" { - return fmt.Errorf("invalid platform osversion %q", platform.OSVersion) - } - if platform.Variant != "" { - return fmt.Errorf("invalid platform variant %q", platform.Variant) - } - return nil + return false } -// ParsePlatform parses a platform string in the format os[/arch[/variant] -// into an OCI image-spec platform structure. -// TODO This is a temporary function - can be replaced by parsing from -// https://github.com/containerd/containerd/pull/1403/files at a later date. -// @jhowardmsft -func ParsePlatform(in string) *specs.Platform { - p := &specs.Platform{} - elements := strings.SplitN(strings.ToLower(in), "/", 3) - if len(elements) == 3 { - p.Variant = elements[2] - } - if len(elements) >= 2 { - p.Architecture = elements[1] - } - if len(elements) >= 1 { - p.OS = elements[0] +// ValidatePlatform determines if a platform structure is valid. +// TODO This is a temporary windows-only function, should be replaced by +// comparison of worker capabilities +func ValidatePlatform(platform specs.Platform) error { + if runtime.GOOS == "windows" { + if !(platform.OS == runtime.GOOS || (LCOWSupported() && platform.OS == "linux")) { + return errors.Errorf("unsupported os %s", platform.OS) + } } - return p + return nil } diff --git a/vendor/github.com/docker/docker/pkg/system/lcow_unix.go b/vendor/github.com/docker/docker/pkg/system/lcow_unix.go index cff33bb408..26397fb8a1 100644 --- a/vendor/github.com/docker/docker/pkg/system/lcow_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/lcow_unix.go @@ -1,6 +1,6 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" // LCOWSupported returns true if Linux containers on Windows are supported. func LCOWSupported() bool { diff --git a/vendor/github.com/docker/docker/pkg/system/lcow_windows.go b/vendor/github.com/docker/docker/pkg/system/lcow_windows.go index e54d01e696..f0139df8f7 100644 --- a/vendor/github.com/docker/docker/pkg/system/lcow_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/lcow_windows.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" // LCOWSupported returns true if Linux containers on Windows are supported. func LCOWSupported() bool { diff --git a/vendor/github.com/docker/docker/pkg/system/lstat_unix.go b/vendor/github.com/docker/docker/pkg/system/lstat_unix.go index bd23c4d50b..de5a1c0fb2 100644 --- a/vendor/github.com/docker/docker/pkg/system/lstat_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/lstat_unix.go @@ -1,8 +1,9 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" import ( + "os" "syscall" ) @@ -13,7 +14,7 @@ import ( func Lstat(path string) (*StatT, error) { s := &syscall.Stat_t{} if err := syscall.Lstat(path, s); err != nil { - return nil, err + return nil, &os.PathError{Op: "Lstat", Path: path, Err: err} } return fromStatT(s) } diff --git a/vendor/github.com/docker/docker/pkg/system/lstat_windows.go b/vendor/github.com/docker/docker/pkg/system/lstat_windows.go index e51df0dafe..359c791d9b 100644 --- a/vendor/github.com/docker/docker/pkg/system/lstat_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/lstat_windows.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "os" diff --git a/vendor/github.com/docker/docker/pkg/system/meminfo.go b/vendor/github.com/docker/docker/pkg/system/meminfo.go index 3b6e947e67..6667eb84dc 100644 --- a/vendor/github.com/docker/docker/pkg/system/meminfo.go +++ b/vendor/github.com/docker/docker/pkg/system/meminfo.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" // MemInfo contains memory statistics of the host system. type MemInfo struct { diff --git a/vendor/github.com/docker/docker/pkg/system/meminfo_linux.go b/vendor/github.com/docker/docker/pkg/system/meminfo_linux.go index 385f1d5e73..d79e8b0765 100644 --- a/vendor/github.com/docker/docker/pkg/system/meminfo_linux.go +++ b/vendor/github.com/docker/docker/pkg/system/meminfo_linux.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "bufio" diff --git a/vendor/github.com/docker/docker/pkg/system/meminfo_solaris.go b/vendor/github.com/docker/docker/pkg/system/meminfo_solaris.go deleted file mode 100644 index 925776e789..0000000000 --- a/vendor/github.com/docker/docker/pkg/system/meminfo_solaris.go +++ /dev/null @@ -1,129 +0,0 @@ -// +build solaris,cgo - -package system - -import ( - "fmt" - "unsafe" -) - -// #cgo CFLAGS: -std=c99 -// #cgo LDFLAGS: -lkstat -// #include -// #include -// #include -// #include -// #include -// #include -// struct swaptable *allocSwaptable(int num) { -// struct swaptable *st; -// struct swapent *swapent; -// st = (struct swaptable *)malloc(num * sizeof(swapent_t) + sizeof (int)); -// swapent = st->swt_ent; -// for (int i = 0; i < num; i++,swapent++) { -// swapent->ste_path = (char *)malloc(MAXPATHLEN * sizeof (char)); -// } -// st->swt_n = num; -// return st; -//} -// void freeSwaptable (struct swaptable *st) { -// struct swapent *swapent = st->swt_ent; -// for (int i = 0; i < st->swt_n; i++,swapent++) { -// free(swapent->ste_path); -// } -// free(st); -// } -// swapent_t getSwapEnt(swapent_t *ent, int i) { -// return ent[i]; -// } -// int64_t getPpKernel() { -// int64_t pp_kernel = 0; -// kstat_ctl_t *ksc; -// kstat_t *ks; -// kstat_named_t *knp; -// kid_t kid; -// -// if ((ksc = kstat_open()) == NULL) { -// return -1; -// } -// if ((ks = kstat_lookup(ksc, "unix", 0, "system_pages")) == NULL) { -// return -1; -// } -// if (((kid = kstat_read(ksc, ks, NULL)) == -1) || -// ((knp = kstat_data_lookup(ks, "pp_kernel")) == NULL)) { -// return -1; -// } -// switch (knp->data_type) { -// case KSTAT_DATA_UINT64: -// pp_kernel = knp->value.ui64; -// break; -// case KSTAT_DATA_UINT32: -// pp_kernel = knp->value.ui32; -// break; -// } -// pp_kernel *= sysconf(_SC_PAGESIZE); -// return (pp_kernel > 0 ? pp_kernel : -1); -// } -import "C" - -// Get the system memory info using sysconf same as prtconf -func getTotalMem() int64 { - pagesize := C.sysconf(C._SC_PAGESIZE) - npages := C.sysconf(C._SC_PHYS_PAGES) - return int64(pagesize * npages) -} - -func getFreeMem() int64 { - pagesize := C.sysconf(C._SC_PAGESIZE) - npages := C.sysconf(C._SC_AVPHYS_PAGES) - return int64(pagesize * npages) -} - -// ReadMemInfo retrieves memory statistics of the host system and returns a -// MemInfo type. -func ReadMemInfo() (*MemInfo, error) { - - ppKernel := C.getPpKernel() - MemTotal := getTotalMem() - MemFree := getFreeMem() - SwapTotal, SwapFree, err := getSysSwap() - - if ppKernel < 0 || MemTotal < 0 || MemFree < 0 || SwapTotal < 0 || - SwapFree < 0 { - return nil, fmt.Errorf("error getting system memory info %v\n", err) - } - - meminfo := &MemInfo{} - // Total memory is total physical memory less than memory locked by kernel - meminfo.MemTotal = MemTotal - int64(ppKernel) - meminfo.MemFree = MemFree - meminfo.SwapTotal = SwapTotal - meminfo.SwapFree = SwapFree - - return meminfo, nil -} - -func getSysSwap() (int64, int64, error) { - var tSwap int64 - var fSwap int64 - var diskblksPerPage int64 - num, err := C.swapctl(C.SC_GETNSWP, nil) - if err != nil { - return -1, -1, err - } - st := C.allocSwaptable(num) - _, err = C.swapctl(C.SC_LIST, unsafe.Pointer(st)) - if err != nil { - C.freeSwaptable(st) - return -1, -1, err - } - - diskblksPerPage = int64(C.sysconf(C._SC_PAGESIZE) >> C.DEV_BSHIFT) - for i := 0; i < int(num); i++ { - swapent := C.getSwapEnt(&st.swt_ent[0], C.int(i)) - tSwap += int64(swapent.ste_pages) * diskblksPerPage - fSwap += int64(swapent.ste_free) * diskblksPerPage - } - C.freeSwaptable(st) - return tSwap, fSwap, nil -} diff --git a/vendor/github.com/docker/docker/pkg/system/meminfo_unsupported.go b/vendor/github.com/docker/docker/pkg/system/meminfo_unsupported.go index 3ce019dffd..56f4494268 100644 --- a/vendor/github.com/docker/docker/pkg/system/meminfo_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/system/meminfo_unsupported.go @@ -1,6 +1,6 @@ -// +build !linux,!windows,!solaris +// +build !linux,!windows -package system +package system // import "github.com/docker/docker/pkg/system" // ReadMemInfo is not supported on platforms other than linux and windows. func ReadMemInfo() (*MemInfo, error) { diff --git a/vendor/github.com/docker/docker/pkg/system/meminfo_windows.go b/vendor/github.com/docker/docker/pkg/system/meminfo_windows.go index 883944a4c5..6ed93f2fe2 100644 --- a/vendor/github.com/docker/docker/pkg/system/meminfo_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/meminfo_windows.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "unsafe" diff --git a/vendor/github.com/docker/docker/pkg/system/mknod.go b/vendor/github.com/docker/docker/pkg/system/mknod.go index 2200ec42da..b132482e03 100644 --- a/vendor/github.com/docker/docker/pkg/system/mknod.go +++ b/vendor/github.com/docker/docker/pkg/system/mknod.go @@ -1,6 +1,6 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" import ( "golang.org/x/sys/unix" diff --git a/vendor/github.com/docker/docker/pkg/system/mknod_windows.go b/vendor/github.com/docker/docker/pkg/system/mknod_windows.go index 2e863c0215..ec89d7a15e 100644 --- a/vendor/github.com/docker/docker/pkg/system/mknod_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/mknod_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package system +package system // import "github.com/docker/docker/pkg/system" // Mknod is not implemented on Windows. func Mknod(path string, mode uint32, dev int) error { diff --git a/vendor/github.com/docker/docker/pkg/system/path.go b/vendor/github.com/docker/docker/pkg/system/path.go index 034c33c877..a3d957afab 100644 --- a/vendor/github.com/docker/docker/pkg/system/path.go +++ b/vendor/github.com/docker/docker/pkg/system/path.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "fmt" @@ -35,7 +35,7 @@ func DefaultPathEnv(os string) string { // This is used, for example, when validating a user provided path in docker cp. // If a drive letter is supplied, it must be the system drive. The drive letter // is always removed. Also, it translates it to OS semantics (IOW / to \). We -// need the path in this syntax so that it can ultimately be contatenated with +// need the path in this syntax so that it can ultimately be concatenated with // a Windows long-path which doesn't support drive-letters. Examples: // C: --> Fail // C:\ --> \ diff --git a/vendor/github.com/docker/docker/pkg/system/path_unix.go b/vendor/github.com/docker/docker/pkg/system/path_unix.go new file mode 100644 index 0000000000..b0b93196a1 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/system/path_unix.go @@ -0,0 +1,10 @@ +// +build !windows + +package system // import "github.com/docker/docker/pkg/system" + +// GetLongPathName converts Windows short pathnames to full pathnames. +// For example C:\Users\ADMIN~1 --> C:\Users\Administrator. +// It is a no-op on non-Windows platforms +func GetLongPathName(path string) (string, error) { + return path, nil +} diff --git a/vendor/github.com/docker/docker/pkg/system/path_windows.go b/vendor/github.com/docker/docker/pkg/system/path_windows.go new file mode 100644 index 0000000000..188f2c2957 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/system/path_windows.go @@ -0,0 +1,24 @@ +package system // import "github.com/docker/docker/pkg/system" + +import "syscall" + +// GetLongPathName converts Windows short pathnames to full pathnames. +// For example C:\Users\ADMIN~1 --> C:\Users\Administrator. +// It is a no-op on non-Windows platforms +func GetLongPathName(path string) (string, error) { + // See https://groups.google.com/forum/#!topic/golang-dev/1tufzkruoTg + p := syscall.StringToUTF16(path) + b := p // GetLongPathName says we can reuse buffer + n, err := syscall.GetLongPathName(&p[0], &b[0], uint32(len(b))) + if err != nil { + return "", err + } + if n > uint32(len(b)) { + b = make([]uint16, n) + _, err = syscall.GetLongPathName(&p[0], &b[0], uint32(len(b))) + if err != nil { + return "", err + } + } + return syscall.UTF16ToString(b), nil +} diff --git a/vendor/github.com/docker/docker/pkg/system/process_unix.go b/vendor/github.com/docker/docker/pkg/system/process_unix.go index 26c8b42c17..0195a891b2 100644 --- a/vendor/github.com/docker/docker/pkg/system/process_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/process_unix.go @@ -1,6 +1,6 @@ -// +build linux freebsd solaris darwin +// +build linux freebsd darwin -package system +package system // import "github.com/docker/docker/pkg/system" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/process_windows.go b/vendor/github.com/docker/docker/pkg/system/process_windows.go new file mode 100644 index 0000000000..4e70c97b18 --- /dev/null +++ b/vendor/github.com/docker/docker/pkg/system/process_windows.go @@ -0,0 +1,18 @@ +package system // import "github.com/docker/docker/pkg/system" + +import "os" + +// IsProcessAlive returns true if process with a given pid is running. +func IsProcessAlive(pid int) bool { + _, err := os.FindProcess(pid) + + return err == nil +} + +// KillProcess force-stops a process. +func KillProcess(pid int) { + p, err := os.FindProcess(pid) + if err == nil { + p.Kill() + } +} diff --git a/vendor/github.com/docker/docker/pkg/system/rm.go b/vendor/github.com/docker/docker/pkg/system/rm.go index 101b569a56..b310991800 100644 --- a/vendor/github.com/docker/docker/pkg/system/rm.go +++ b/vendor/github.com/docker/docker/pkg/system/rm.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "os" @@ -26,7 +26,7 @@ func EnsureRemoveAll(dir string) error { // track retries exitOnErr := make(map[string]int) - maxRetry := 5 + maxRetry := 50 // Attempt to unmount anything beneath this dir first mount.RecursiveUnmount(dir) @@ -34,7 +34,7 @@ func EnsureRemoveAll(dir string) error { for { err := os.RemoveAll(dir) if err == nil { - return err + return nil } pe, ok := err.(*os.PathError) diff --git a/vendor/github.com/docker/docker/pkg/system/stat_darwin.go b/vendor/github.com/docker/docker/pkg/system/stat_darwin.go index 715f05b938..c1c0ee9f38 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_darwin.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_darwin.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/stat_freebsd.go b/vendor/github.com/docker/docker/pkg/system/stat_freebsd.go index 715f05b938..c1c0ee9f38 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_freebsd.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_freebsd.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/stat_linux.go b/vendor/github.com/docker/docker/pkg/system/stat_linux.go index 1939f95181..98c9eb18d1 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_linux.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_linux.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go b/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go index b607dea946..756b92d1e6 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_openbsd.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/stat_solaris.go b/vendor/github.com/docker/docker/pkg/system/stat_solaris.go index b607dea946..756b92d1e6 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_solaris.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_solaris.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/stat_unix.go b/vendor/github.com/docker/docker/pkg/system/stat_unix.go index 91c7d121cc..86bb6dd55e 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_unix.go @@ -1,8 +1,9 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" import ( + "os" "syscall" ) @@ -47,6 +48,11 @@ func (s StatT) Mtim() syscall.Timespec { return s.mtim } +// IsDir reports whether s describes a directory. +func (s StatT) IsDir() bool { + return s.mode&syscall.S_IFDIR != 0 +} + // Stat takes a path to a file and returns // a system.StatT type pertaining to that file. // @@ -54,7 +60,7 @@ func (s StatT) Mtim() syscall.Timespec { func Stat(path string) (*StatT, error) { s := &syscall.Stat_t{} if err := syscall.Stat(path, s); err != nil { - return nil, err + return nil, &os.PathError{Op: "Stat", Path: path, Err: err} } return fromStatT(s) } diff --git a/vendor/github.com/docker/docker/pkg/system/stat_windows.go b/vendor/github.com/docker/docker/pkg/system/stat_windows.go index 6c63972682..b2456cb887 100644 --- a/vendor/github.com/docker/docker/pkg/system/stat_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/stat_windows.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "os" diff --git a/vendor/github.com/docker/docker/pkg/system/syscall_unix.go b/vendor/github.com/docker/docker/pkg/system/syscall_unix.go index 49dbdd3781..919a412a7b 100644 --- a/vendor/github.com/docker/docker/pkg/system/syscall_unix.go +++ b/vendor/github.com/docker/docker/pkg/system/syscall_unix.go @@ -1,6 +1,6 @@ // +build linux freebsd -package system +package system // import "github.com/docker/docker/pkg/system" import "golang.org/x/sys/unix" diff --git a/vendor/github.com/docker/docker/pkg/system/syscall_windows.go b/vendor/github.com/docker/docker/pkg/system/syscall_windows.go index 23e9b207c7..4ae92fa6c7 100644 --- a/vendor/github.com/docker/docker/pkg/system/syscall_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/syscall_windows.go @@ -1,16 +1,63 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( + "fmt" + "syscall" "unsafe" "github.com/sirupsen/logrus" "golang.org/x/sys/windows" ) +const ( + OWNER_SECURITY_INFORMATION = 0x00000001 + GROUP_SECURITY_INFORMATION = 0x00000002 + DACL_SECURITY_INFORMATION = 0x00000004 + SACL_SECURITY_INFORMATION = 0x00000008 + LABEL_SECURITY_INFORMATION = 0x00000010 + ATTRIBUTE_SECURITY_INFORMATION = 0x00000020 + SCOPE_SECURITY_INFORMATION = 0x00000040 + PROCESS_TRUST_LABEL_SECURITY_INFORMATION = 0x00000080 + ACCESS_FILTER_SECURITY_INFORMATION = 0x00000100 + BACKUP_SECURITY_INFORMATION = 0x00010000 + PROTECTED_DACL_SECURITY_INFORMATION = 0x80000000 + PROTECTED_SACL_SECURITY_INFORMATION = 0x40000000 + UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000 + UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000 +) + +const ( + SE_UNKNOWN_OBJECT_TYPE = iota + SE_FILE_OBJECT + SE_SERVICE + SE_PRINTER + SE_REGISTRY_KEY + SE_LMSHARE + SE_KERNEL_OBJECT + SE_WINDOW_OBJECT + SE_DS_OBJECT + SE_DS_OBJECT_ALL + SE_PROVIDER_DEFINED_OBJECT + SE_WMIGUID_OBJECT + SE_REGISTRY_WOW64_32KEY +) + +const ( + SeTakeOwnershipPrivilege = "SeTakeOwnershipPrivilege" +) + +const ( + ContainerAdministratorSidString = "S-1-5-93-2-1" + ContainerUserSidString = "S-1-5-93-2-2" +) + var ( - ntuserApiset = windows.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") - procGetVersionExW = modkernel32.NewProc("GetVersionExW") - procGetProductInfo = modkernel32.NewProc("GetProductInfo") + ntuserApiset = windows.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") + modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") + procGetVersionExW = modkernel32.NewProc("GetVersionExW") + procGetProductInfo = modkernel32.NewProc("GetProductInfo") + procSetNamedSecurityInfo = modadvapi32.NewProc("SetNamedSecurityInfoW") + procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl") ) // OSVersion is a wrapper for Windows version information @@ -53,6 +100,10 @@ func GetOSVersion() OSVersion { return osv } +func (osv OSVersion) ToString() string { + return fmt.Sprintf("%d.%d.%d", osv.MajorVersion, osv.MinorVersion, osv.Build) +} + // IsWindowsClient returns true if the SKU is client // @engine maintainers - this function should not be removed or modified as it // is used to enforce licensing restrictions on Windows. @@ -120,3 +171,23 @@ func HasWin32KSupport() bool { // APIs. return ntuserApiset.Load() == nil } + +func SetNamedSecurityInfo(objectName *uint16, objectType uint32, securityInformation uint32, sidOwner *windows.SID, sidGroup *windows.SID, dacl *byte, sacl *byte) (result error) { + r0, _, _ := syscall.Syscall9(procSetNamedSecurityInfo.Addr(), 7, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(sidOwner)), uintptr(unsafe.Pointer(sidGroup)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0) + if r0 != 0 { + result = syscall.Errno(r0) + } + return +} + +func GetSecurityDescriptorDacl(securityDescriptor *byte, daclPresent *uint32, dacl **byte, daclDefaulted *uint32) (result error) { + r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(securityDescriptor)), uintptr(unsafe.Pointer(daclPresent)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(daclDefaulted)), 0, 0) + if r1 == 0 { + if e1 != 0 { + result = syscall.Errno(e1) + } else { + result = syscall.EINVAL + } + } + return +} diff --git a/vendor/github.com/docker/docker/pkg/system/umask.go b/vendor/github.com/docker/docker/pkg/system/umask.go index 5a10eda5af..9912a2babb 100644 --- a/vendor/github.com/docker/docker/pkg/system/umask.go +++ b/vendor/github.com/docker/docker/pkg/system/umask.go @@ -1,6 +1,6 @@ // +build !windows -package system +package system // import "github.com/docker/docker/pkg/system" import ( "golang.org/x/sys/unix" diff --git a/vendor/github.com/docker/docker/pkg/system/umask_windows.go b/vendor/github.com/docker/docker/pkg/system/umask_windows.go index 13f1de1769..fc62388c38 100644 --- a/vendor/github.com/docker/docker/pkg/system/umask_windows.go +++ b/vendor/github.com/docker/docker/pkg/system/umask_windows.go @@ -1,6 +1,4 @@ -// +build windows - -package system +package system // import "github.com/docker/docker/pkg/system" // Umask is not supported on the windows platform. func Umask(newmask int) (oldmask int, err error) { diff --git a/vendor/github.com/docker/docker/pkg/system/utimes_freebsd.go b/vendor/github.com/docker/docker/pkg/system/utimes_freebsd.go index 6a77524376..ed1b9fad59 100644 --- a/vendor/github.com/docker/docker/pkg/system/utimes_freebsd.go +++ b/vendor/github.com/docker/docker/pkg/system/utimes_freebsd.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/utimes_linux.go b/vendor/github.com/docker/docker/pkg/system/utimes_linux.go index edc588a63f..0afe854589 100644 --- a/vendor/github.com/docker/docker/pkg/system/utimes_linux.go +++ b/vendor/github.com/docker/docker/pkg/system/utimes_linux.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import ( "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go b/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go index 139714544d..095e072e1d 100644 --- a/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go @@ -1,6 +1,6 @@ // +build !linux,!freebsd -package system +package system // import "github.com/docker/docker/pkg/system" import "syscall" diff --git a/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go b/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go index 98b111be42..66d4895b27 100644 --- a/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go +++ b/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go @@ -1,4 +1,4 @@ -package system +package system // import "github.com/docker/docker/pkg/system" import "golang.org/x/sys/unix" diff --git a/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go b/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go index 0114f2227c..d780a90cd3 100644 --- a/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go +++ b/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go @@ -1,6 +1,6 @@ // +build !linux -package system +package system // import "github.com/docker/docker/pkg/system" // Lgetxattr is not supported on platforms other than linux. func Lgetxattr(path string, attr string) ([]byte, error) { diff --git a/vendor/github.com/docker/docker/vendor.conf b/vendor/github.com/docker/docker/vendor.conf index ee52979e67..805f89626e 100644 --- a/vendor/github.com/docker/docker/vendor.conf +++ b/vendor/github.com/docker/docker/vendor.conf @@ -1,149 +1,161 @@ # the following lines are in sorted order, FYI github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 -github.com/Microsoft/hcsshim v0.6.5 -github.com/Microsoft/go-winio v0.4.5 -github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 +github.com/Microsoft/hcsshim v0.8.6 +github.com/Microsoft/go-winio v0.4.11 github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git -github.com/gorilla/context v1.1 -github.com/gorilla/mux v1.1 -github.com/Microsoft/opengcs v0.3.4 +github.com/golang/gddo 9b12a26f3fbd7397dee4e20939ddca719d840d2a +github.com/gorilla/mux v1.7.0 +github.com/Microsoft/opengcs v0.3.9 github.com/kr/pty 5cf931ef8f github.com/mattn/go-shellwords v1.0.3 -github.com/sirupsen/logrus v1.0.3 +github.com/sirupsen/logrus v1.0.6 github.com/tchap/go-patricia v2.2.6 github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 -golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 -golang.org/x/sys 8dbc5d05d6edcc104950cc299a1ce6641235bc86 -github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1 -github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d -golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756 -github.com/stretchr/testify 4d4bfba8f1d1027c4fdbe371823030df51419987 -github.com/pmezard/go-difflib v1.0.0 -github.com/gotestyourself/gotestyourself v1.1.0 +golang.org/x/net a680a1efc54dd51c040b3b5ce4939ea3cf2ea0d1 +golang.org/x/sys 41f3e6584952bb034a481797859f6ab34b6803bd +github.com/docker/go-units 47565b4f722fb6ceae66b95f853feed578a4a51c # v0.3.3 +github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0 +golang.org/x/text f21a4dfb5e38f5895301dc265a8def02365cc3d0 # v0.3.0 +gotest.tools v2.1.0 +github.com/google/go-cmp v0.2.0 github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5 -github.com/imdario/mergo 0.2.1 -golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0 - -github.com/containerd/continuity 22694c680ee48fb8f50015b44618517e2bde77e8 -github.com/moby/buildkit aaff9d591ef128560018433fe61beb802e149de8 -github.com/tonistiigi/fsutil dea3a0da73aee887fc02142d995be764106ac5e2 +github.com/imdario/mergo v0.3.6 +golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca + +# buildkit +github.com/moby/buildkit 34ff9c2366a878ada7938d2f9ede71741b0a220c +github.com/tonistiigi/fsutil 2862f6bc5ac9b97124e552a5c108230b38a1b0ca +github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 +github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7 +github.com/google/shlex 6f45313302b9c56850fc17f99e40caebce98c716 +github.com/opentracing-contrib/go-stdlib b1a47cfbdd7543e70e9ef3e73d0802ad306cc1cc +github.com/mitchellh/hashstructure 2bca23e0e452137f789efbc8610126fd8b94f73b #get libnetwork packages -github.com/docker/libnetwork 68f1039f172434709a4550fe92e3e058406c74ce + +# When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy.installer accordingly +github.com/docker/libnetwork 1a06131fb8a047d919f7deaf02a4c414d7884b83 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b -github.com/hashicorp/memberlist v0.1.0 +github.com/hashicorp/memberlist 3d8438da9589e7b608a83ffac1ef8211486bcb7c github.com/sean-/seed e2103e2c35297fb7e17febb81e49b312087a2372 -github.com/hashicorp/go-sockaddr acd314c5781ea706c710d9ea70069fd2e110d61d +github.com/hashicorp/go-sockaddr 6d291a969b86c4b633730bfc6b8b9d64c3aafed9 github.com/hashicorp/go-multierror fcdddc395df1ddf4247c69bd436e84cfa0733f7e github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870 -github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef +github.com/docker/libkv 458977154600b9f23984d9f4b82e79570b5ae12b github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25 -github.com/vishvananda/netlink bd6d5de5ccef2d66b0a26177928d0d8895d7f969 -github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060 +github.com/vishvananda/netlink b2de5d10e38ecce8607e6b438b6d174f389a004e + +# When updating, consider updating TOMLV_COMMIT in hack/dockerfile/install/tomlv.installer accordingly +github.com/BurntSushi/toml 3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005 # v0.3.1 github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d -github.com/coreos/etcd v3.2.1 +github.com/coreos/etcd v3.3.9 github.com/coreos/go-semver v0.2.0 -github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065 +github.com/ugorji/go v1.1.1 github.com/hashicorp/consul v0.5.2 -github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904 -github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7 +github.com/miekg/dns v1.0.7 +github.com/ishidawataru/sctp 07191f837fedd2f13d1ec7b5f885f0f3ec54b1cb +go.etcd.io/bbolt v1.3.1-etcd.8 # get graph and distribution packages -github.com/docker/distribution edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c -github.com/vbatts/tar-split v0.10.1 -github.com/opencontainers/go-digest a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb +github.com/docker/distribution 0d3efadf0154c2b8a4e7b6621fff9809655cc580 +github.com/vbatts/tar-split v0.11.0 +github.com/opencontainers/go-digest v1.0.0-rc1 # get go-zfs packages github.com/mistifyio/go-zfs 22c9b32c84eb0d0c6f4043b6e90fc94073de92fa github.com/pborman/uuid v1.0 -google.golang.org/grpc v1.3.0 - -# When updating, also update RUNC_COMMIT in hack/dockerfile/binaries-commits accordingly -github.com/opencontainers/runc 0351df1c5a66838d0c392b4ac4cf9450de844e2d -github.com/opencontainers/image-spec 372ad780f63454fbbbbcc7cf80e5b90245c13e13 -github.com/opencontainers/runtime-spec v1.0.0 +google.golang.org/grpc v1.12.0 +# The version of runc should match the version that is used by the containerd +# version that is used. If you need to update runc, open a pull request in +# the containerd project first, and update both after that is merged. +# This commit does not need to match RUNC_COMMIT as it is used for helper +# packages but should be newer or equal. +github.com/opencontainers/runc 12f6a991201fdb8f82579582d5e00e28fba06d0a +github.com/opencontainers/runtime-spec 29686dbc5559d93fb1ef402eeda3e35c38d75af4 # v1.0.1-59-g29686db +github.com/opencontainers/image-spec v1.0.1 github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0 # libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json) -github.com/coreos/go-systemd v4 +github.com/coreos/go-systemd v17 github.com/godbus/dbus v4.0.0 github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852 -github.com/golang/protobuf 7a211bcf3bce0e3f1d74f9894916e6f116ae83b4 +github.com/golang/protobuf v1.1.0 # gelf logging driver deps -github.com/Graylog2/go-gelf v2 +github.com/Graylog2/go-gelf 4143646226541087117ff2f83334ea48b3201841 -github.com/fluent/fluent-logger-golang v1.2.1 +github.com/fluent/fluent-logger-golang v1.3.0 # fluent-logger-golang deps github.com/philhofer/fwd 98c11a7a6ec829d672b03833c3d69a7fae1ca972 -github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c +github.com/tinylib/msgp 3b556c64540842d4f82967be066a7f7fffc3adad # fsnotify -github.com/fsnotify/fsnotify v1.4.2 +github.com/fsnotify/fsnotify v1.4.7 # awslogs deps -github.com/aws/aws-sdk-go v1.4.22 -github.com/go-ini/ini 060d7da055ba6ec5ea7a31f116332fe5efa04ce0 +github.com/aws/aws-sdk-go v1.12.66 +github.com/go-ini/ini v1.25.4 github.com/jmespath/go-jmespath 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74 # logentries github.com/bsphere/le_go 7a984a84b5492ae539b79b62fb4a10afc63c7bcf # gcplogs deps -golang.org/x/oauth2 96382aa079b72d8c014eb0c50f6c223d1e6a2de0 -google.golang.org/api 3cc2e591b550923a2c5f0ab5a803feda924d5823 -cloud.google.com/go 9d965e63e8cceb1b5d7977a202f0fcb8866d6525 -github.com/googleapis/gax-go da06d194a00e19ce00d9011a13931c3f6f6887c7 -google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 +golang.org/x/oauth2 ec22f46f877b4505e0117eeaab541714644fdd28 +google.golang.org/api de943baf05a022a8f921b544b7827bacaba1aed5 +go.opencensus.io v0.11.0 +cloud.google.com/go v0.23.0 +github.com/googleapis/gax-go v2.0.0 +google.golang.org/genproto 694d95ba50e67b2e363f3483057db5d4910c18f9 # containerd -github.com/containerd/containerd 06b9cb35161009dcb7123345749fef02f7cea8e0 -github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4 +github.com/containerd/containerd e6b3f5632f50dbc4e9cb6288d911bf4f5e95b18e # v1.2.4 +github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c +github.com/containerd/continuity 004b46473808b3e7a4a3049c20e4376c91eb966d +github.com/containerd/cgroups 5e610833b72089b37d0e615de9a92dfc043757c2 +github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23 +github.com/containerd/go-runc 5a6d9f37cfa36b15efba46dc7ea349fa9b7143c3 +github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40 +github.com/containerd/ttrpc 2a805f71863501300ae1976d29f0454ae003e85a +github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef # cluster -github.com/docker/swarmkit 872861d2ae46958af7ead1d5fffb092c73afbaf0 -github.com/gogo/protobuf v0.4 -github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a -github.com/google/certificate-transparency d90e65c3a07988180c5b1ece71791c0b6506826e -golang.org/x/crypto 558b6879de74bc843225cde5686419267ff707ca -golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb +github.com/docker/swarmkit ebfb0aa1118ebfd35a224d72a5d337ce0addd907 +github.com/gogo/protobuf v1.0.0 +github.com/cloudflare/cfssl 1.3.2 +github.com/fernet/fernet-go 1b2437bc582b3cfbb341ee5a29f8ef5b42912ff2 +github.com/google/certificate-transparency-go v1.0.20 +golang.org/x/crypto 0709b304e793a5edb4a2c0145f281ecdc20838a4 +golang.org/x/time fbb02b2291d28baffd63558aa44b4b56f178d650 github.com/hashicorp/go-memdb cb9a474f84cc5e41b273b20c6927680b2a8776ad -github.com/hashicorp/go-immutable-radix 8e8ed81f8f0bf1bdd829593fdd5c29922c1ea990 -github.com/hashicorp/golang-lru a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4 -github.com/coreos/pkg fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8 +github.com/hashicorp/go-immutable-radix 826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git +github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3 +github.com/coreos/pkg v3 github.com/pivotal-golang/clock 3fd3c1944c59d9742e1cd333672181cd1a6f9fa0 -github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e -github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 -github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 -github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 -github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 +github.com/prometheus/client_golang v0.8.0 +github.com/beorn7/perks 3a771d992973f24aa725d07868b467d1ddfceaf +github.com/prometheus/client_model 6f3806018612930941127f2a7c6c453ba2c527d2 +github.com/prometheus/common 7600349dcfe1abd18d72d3a1770870d9800a7801 +github.com/prometheus/procfs 7d6f385de8bea29190f15ba9931442a0eaef9af7 github.com/matttproud/golang_protobuf_extensions v1.0.0 -github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 -github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0 +github.com/pkg/errors 645ef00459ed84a119197bfb8d8205042c6df63d # v0.8.0 +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 # cli -github.com/spf13/cobra v1.5.1 https://github.com/dnephin/cobra.git -github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 -github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 -github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty +github.com/spf13/cobra v0.0.3 +github.com/spf13/pflag v1.0.1 +github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0 +github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b # metrics github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 -github.com/opencontainers/selinux v1.0.0-rc1 - -# archive/tar -# mkdir -p ./vendor/archive -# git clone git://github.com/tonistiigi/go-1.git ./go -# git --git-dir ./go/.git --work-tree ./go checkout revert-prefix-ignore -# cp -a go/src/archive/tar ./vendor/archive/tar -# rm -rf ./go -# vndr +github.com/opencontainers/selinux b6fa367ed7f534f9ba25391cc2d467085dbb445a diff --git a/vendor/github.com/docker/libnetwork/LICENSE b/vendor/github.com/docker/libnetwork/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/docker/libnetwork/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/docker/libnetwork/README.md b/vendor/github.com/docker/libnetwork/README.md new file mode 100644 index 0000000000..a9020381ab --- /dev/null +++ b/vendor/github.com/docker/libnetwork/README.md @@ -0,0 +1,100 @@ +# libnetwork - networking for containers + +[![Circle CI](https://circleci.com/gh/docker/libnetwork/tree/master.svg?style=svg)](https://circleci.com/gh/docker/libnetwork/tree/master) [![Coverage Status](https://coveralls.io/repos/docker/libnetwork/badge.svg)](https://coveralls.io/r/docker/libnetwork) [![GoDoc](https://godoc.org/github.com/docker/libnetwork?status.svg)](https://godoc.org/github.com/docker/libnetwork) [![Go Report Card](https://goreportcard.com/badge/github.com/docker/libnetwork)](https://goreportcard.com/report/github.com/docker/libnetwork) + +Libnetwork provides a native Go implementation for connecting containers + +The goal of libnetwork is to deliver a robust Container Network Model that provides a consistent programming interface and the required network abstractions for applications. + +#### Design +Please refer to the [design](docs/design.md) for more information. + +#### Using libnetwork + +There are many networking solutions available to suit a broad range of use-cases. libnetwork uses a driver / plugin model to support all of these solutions while abstracting the complexity of the driver implementations by exposing a simple and consistent Network Model to users. + + +```go +import ( + "fmt" + "log" + + "github.com/docker/docker/pkg/reexec" + "github.com/docker/libnetwork" + "github.com/docker/libnetwork/config" + "github.com/docker/libnetwork/netlabel" + "github.com/docker/libnetwork/options" +) + +func main() { + if reexec.Init() { + return + } + + // Select and configure the network driver + networkType := "bridge" + + // Create a new controller instance + driverOptions := options.Generic{} + genericOption := make(map[string]interface{}) + genericOption[netlabel.GenericData] = driverOptions + controller, err := libnetwork.New(config.OptionDriverConfig(networkType, genericOption)) + if err != nil { + log.Fatalf("libnetwork.New: %s", err) + } + + // Create a network for containers to join. + // NewNetwork accepts Variadic optional arguments that libnetwork and Drivers can use. + network, err := controller.NewNetwork(networkType, "network1", "") + if err != nil { + log.Fatalf("controller.NewNetwork: %s", err) + } + + // For each new container: allocate IP and interfaces. The returned network + // settings will be used for container infos (inspect and such), as well as + // iptables rules for port publishing. This info is contained or accessible + // from the returned endpoint. + ep, err := network.CreateEndpoint("Endpoint1") + if err != nil { + log.Fatalf("network.CreateEndpoint: %s", err) + } + + // Create the sandbox for the container. + // NewSandbox accepts Variadic optional arguments which libnetwork can use. + sbx, err := controller.NewSandbox("container1", + libnetwork.OptionHostname("test"), + libnetwork.OptionDomainname("docker.io")) + if err != nil { + log.Fatalf("controller.NewSandbox: %s", err) + } + + // A sandbox can join the endpoint via the join api. + err = ep.Join(sbx) + if err != nil { + log.Fatalf("ep.Join: %s", err) + } + + // libnetwork client can check the endpoint's operational data via the Info() API + epInfo, err := ep.DriverInfo() + if err != nil { + log.Fatalf("ep.DriverInfo: %s", err) + } + + macAddress, ok := epInfo[netlabel.MacAddress] + if !ok { + log.Fatalf("failed to get mac address from endpoint info") + } + + fmt.Printf("Joined endpoint %s (%s) to sandbox %s (%s)\n", ep.Name(), macAddress, sbx.ContainerID(), sbx.Key()) +} +``` + +## Future +Please refer to [roadmap](ROADMAP.md) for more information. + +## Contributing + +Want to hack on libnetwork? [Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) apply. + +## Copyright and license +Code and documentation copyright 2015 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons. diff --git a/vendor/github.com/docker/libnetwork/ipamutils/utils.go b/vendor/github.com/docker/libnetwork/ipamutils/utils.go new file mode 100644 index 0000000000..3fd37cd884 --- /dev/null +++ b/vendor/github.com/docker/libnetwork/ipamutils/utils.go @@ -0,0 +1,135 @@ +// Package ipamutils provides utility functions for ipam management +package ipamutils + +import ( + "fmt" + "net" + "sync" +) + +var ( + // PredefinedLocalScopeDefaultNetworks contains a list of 31 IPv4 private networks with host size 16 and 12 + // (172.17-31.x.x/16, 192.168.x.x/20) which do not overlap with the networks in `PredefinedGlobalScopeDefaultNetworks` + PredefinedLocalScopeDefaultNetworks []*net.IPNet + // PredefinedGlobalScopeDefaultNetworks contains a list of 64K IPv4 private networks with host size 8 + // (10.x.x.x/24) which do not overlap with the networks in `PredefinedLocalScopeDefaultNetworks` + PredefinedGlobalScopeDefaultNetworks []*net.IPNet + mutex sync.Mutex + localScopeDefaultNetworks = []*NetworkToSplit{{"172.17.0.0/16", 16}, {"172.18.0.0/16", 16}, {"172.19.0.0/16", 16}, + {"172.20.0.0/14", 16}, {"172.24.0.0/14", 16}, {"172.28.0.0/14", 16}, + {"192.168.0.0/16", 20}} + globalScopeDefaultNetworks = []*NetworkToSplit{{"10.0.0.0/8", 24}} +) + +// NetworkToSplit represent a network that has to be split in chunks with mask length Size. +// Each subnet in the set is derived from the Base pool. Base is to be passed +// in CIDR format. +// Example: a Base "10.10.0.0/16 with Size 24 will define the set of 256 +// 10.10.[0-255].0/24 address pools +type NetworkToSplit struct { + Base string `json:"base"` + Size int `json:"size"` +} + +func init() { + var err error + if PredefinedGlobalScopeDefaultNetworks, err = splitNetworks(globalScopeDefaultNetworks); err != nil { + //we are going to panic in case of error as we should never get into this state + panic("InitAddressPools failed to initialize the global scope default address pool") + } + + if PredefinedLocalScopeDefaultNetworks, err = splitNetworks(localScopeDefaultNetworks); err != nil { + //we are going to panic in case of error as we should never get into this state + panic("InitAddressPools failed to initialize the local scope default address pool") + } +} + +// configDefaultNetworks configures local as well global default pool based on input +func configDefaultNetworks(defaultAddressPool []*NetworkToSplit, result *[]*net.IPNet) error { + mutex.Lock() + defer mutex.Unlock() + defaultNetworks, err := splitNetworks(defaultAddressPool) + if err != nil { + return err + } + *result = defaultNetworks + return nil +} + +// GetGlobalScopeDefaultNetworks returns PredefinedGlobalScopeDefaultNetworks +func GetGlobalScopeDefaultNetworks() []*net.IPNet { + mutex.Lock() + defer mutex.Unlock() + return PredefinedGlobalScopeDefaultNetworks +} + +// GetLocalScopeDefaultNetworks returns PredefinedLocalScopeDefaultNetworks +func GetLocalScopeDefaultNetworks() []*net.IPNet { + mutex.Lock() + defer mutex.Unlock() + return PredefinedLocalScopeDefaultNetworks +} + +// ConfigGlobalScopeDefaultNetworks configures global default pool. +// Ideally this will be called from SwarmKit as part of swarm init +func ConfigGlobalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { + if defaultAddressPool == nil { + defaultAddressPool = globalScopeDefaultNetworks + } + return configDefaultNetworks(defaultAddressPool, &PredefinedGlobalScopeDefaultNetworks) +} + +// ConfigLocalScopeDefaultNetworks configures local default pool. +// Ideally this will be called during libnetwork init +func ConfigLocalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { + if defaultAddressPool == nil { + return nil + } + return configDefaultNetworks(defaultAddressPool, &PredefinedLocalScopeDefaultNetworks) +} + +// splitNetworks takes a slice of networks, split them accordingly and returns them +func splitNetworks(list []*NetworkToSplit) ([]*net.IPNet, error) { + localPools := make([]*net.IPNet, 0, len(list)) + + for _, p := range list { + _, b, err := net.ParseCIDR(p.Base) + if err != nil { + return nil, fmt.Errorf("invalid base pool %q: %v", p.Base, err) + } + ones, _ := b.Mask.Size() + if p.Size <= 0 || p.Size < ones { + return nil, fmt.Errorf("invalid pools size: %d", p.Size) + } + localPools = append(localPools, splitNetwork(p.Size, b)...) + } + return localPools, nil +} + +func splitNetwork(size int, base *net.IPNet) []*net.IPNet { + one, bits := base.Mask.Size() + mask := net.CIDRMask(size, bits) + n := 1 << uint(size-one) + s := uint(bits - size) + list := make([]*net.IPNet, 0, n) + + for i := 0; i < n; i++ { + ip := copyIP(base.IP) + addIntToIP(ip, uint(i<= 0; i-- { + array[i] |= (byte)(ordinal & 0xff) + ordinal >>= 8 + } +} diff --git a/vendor/github.com/docker/libnetwork/vendor.conf b/vendor/github.com/docker/libnetwork/vendor.conf new file mode 100644 index 0000000000..865704ab4e --- /dev/null +++ b/vendor/github.com/docker/libnetwork/vendor.conf @@ -0,0 +1,50 @@ +github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 +github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 +github.com/Microsoft/go-winio v0.4.11 +github.com/Microsoft/hcsshim v0.7.3 +github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec +github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 +github.com/codegangsta/cli a65b733b303f0055f8d324d805f393cd3e7a7904 +github.com/containerd/continuity d3c23511c1bf5851696cba83143d9cbcd666869b +github.com/coreos/etcd v3.2.1 +github.com/coreos/go-semver v0.2.0 +github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d +go.etcd.io/bbolt v1.3.1-etcd.8 + +github.com/docker/docker 162ba6016def672690ee4a1f3978368853a1e149 +github.com/docker/go-connections 7beb39f0b969b075d1325fecb092faf27fd357b6 +github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 +github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1 +github.com/docker/libkv 458977154600b9f23984d9f4b82e79570b5ae12b + +github.com/godbus/dbus v4.0.0 +github.com/gogo/protobuf v1.0.0 +github.com/gorilla/context v1.1 +github.com/gorilla/mux v1.1 +github.com/hashicorp/consul v0.5.2 +github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b +github.com/hashicorp/go-multierror fcdddc395df1ddf4247c69bd436e84cfa0733f7e +github.com/hashicorp/memberlist 3d8438da9589e7b608a83ffac1ef8211486bcb7c +github.com/sean-/seed e2103e2c35297fb7e17febb81e49b312087a2372 +github.com/hashicorp/go-sockaddr 6d291a969b86c4b633730bfc6b8b9d64c3aafed9 +github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870 +github.com/mattn/go-shellwords v1.0.3 +github.com/miekg/dns v1.0.7 +github.com/opencontainers/go-digest v1.0.0-rc1 +github.com/opencontainers/image-spec v1.0.1 +github.com/opencontainers/runc 96ec2177ae841256168fcf76954f7177af9446eb +github.com/opencontainers/runtime-spec v1.0.1 +github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374 +github.com/sirupsen/logrus v1.0.3 +github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065 +github.com/vishvananda/netlink b2de5d10e38ecce8607e6b438b6d174f389a004e +github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25 +golang.org/x/crypto 1a580b3eff7814fc9b40602fd35256c63b50f491 +golang.org/x/net 0ed95abb35c445290478a5348a7b38bb154135fd +golang.org/x/sys 37707fdb30a5b38865cfb95e5aab41707daec7fd +golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5 +github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9 +github.com/ishidawataru/sctp 07191f837fedd2f13d1ec7b5f885f0f3ec54b1cb + +gotest.tools v2.1.0 +github.com/google/go-cmp v0.2.0 diff --git a/vendor/github.com/fsouza/go-dockerclient/auth.go b/vendor/github.com/fsouza/go-dockerclient/auth.go index acb3a02be7..4335d6e063 100644 --- a/vendor/github.com/fsouza/go-dockerclient/auth.go +++ b/vendor/github.com/fsouza/go-dockerclient/auth.go @@ -32,6 +32,9 @@ type AuthConfiguration struct { // see https://godoc.org/github.com/docker/docker/api/types#AuthConfig // It can be used in place of password not in conjunction with it IdentityToken string `json:"identitytoken,omitempty"` + + // RegistryToken can be supplied with the registrytoken + RegistryToken string `json:"registrytoken,omitempty"` } // AuthConfigurations represents authentication options to use for the @@ -50,6 +53,7 @@ type dockerConfig struct { Auth string `json:"auth"` Email string `json:"email"` IdentityToken string `json:"identitytoken"` + RegistryToken string `json:"registrytoken"` } // NewAuthConfigurationsFromFile returns AuthConfigurations from a path containing JSON @@ -162,6 +166,11 @@ func authConfigs(confs map[string]dockerConfig) (*AuthConfigurations, error) { authConfig.IdentityToken = conf.IdentityToken } + // if registrytoken provided then zero the password and set it + if conf.RegistryToken != "" { + authConfig.Password = "" + authConfig.RegistryToken = conf.RegistryToken + } c.Configs[reg] = authConfig } diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go index a13ee7cca2..7d7cf496a6 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive.go @@ -71,7 +71,7 @@ type TarOptions struct { NoLchown bool UIDMaps []idtools.IDMap GIDMaps []idtools.IDMap - ChownOpts *idtools.IDPair + ChownOpts *idtools.Identity IncludeSourceDir bool // WhiteoutFormat is the expected on disk format for whiteout files. // This format will be converted to the standard format on pack @@ -292,9 +292,9 @@ type tarAppender struct { Buffer *bufio.Writer // for hardlink mapping - SeenFiles map[uint64]string - IDMappings *idtools.IDMappings - ChownOpts *idtools.IDPair + SeenFiles map[uint64]string + IdentityMapping *idtools.IdentityMapping + ChownOpts *idtools.Identity // For packing and unpacking whiteout files in the // non standard format. The whiteout files defined @@ -303,13 +303,13 @@ type tarAppender struct { WhiteoutConverter tarWhiteoutConverter } -func newTarAppender(idMapping *idtools.IDMappings, writer io.Writer, chownOpts *idtools.IDPair) *tarAppender { +func newTarAppender(idMapping *idtools.IdentityMapping, writer io.Writer, chownOpts *idtools.Identity) *tarAppender { return &tarAppender{ - SeenFiles: make(map[uint64]string), - TarWriter: tar.NewWriter(writer), - Buffer: pools.BufioWriter32KPool.Get(nil), - IDMappings: idMapping, - ChownOpts: chownOpts, + SeenFiles: make(map[uint64]string), + TarWriter: tar.NewWriter(writer), + Buffer: pools.BufioWriter32KPool.Get(nil), + IdentityMapping: idMapping, + ChownOpts: chownOpts, } } @@ -364,12 +364,12 @@ func (ta *tarAppender) addTarFile(path, name string) error { //by the kernel and already have proper ownership relative to the host if !isOverlayWhiteout && !strings.HasPrefix(filepath.Base(hdr.Name), WhiteoutPrefix) && - !ta.IDMappings.Empty() { - fileIDPair, err := getFileUIDGID(fi.Sys()) + !ta.IdentityMapping.Empty() { + fileIdentity, err := getFileIdentity(fi.Sys()) if err != nil { return err } - hdr.Uid, hdr.Gid, err = ta.IDMappings.ToContainer(fileIDPair) + hdr.Uid, hdr.Gid, err = ta.IdentityMapping.ToContainer(fileIdentity) if err != nil { return err } diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go index 2633f50206..80199d513d 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_unix.go @@ -48,13 +48,13 @@ func getInodeFromStat(stat interface{}) (inode uint64, err error) { return } -func getFileUIDGID(stat interface{}) (idtools.IDPair, error) { +func getFileIdentity(stat interface{}) (idtools.Identity, error) { s, ok := stat.(*syscall.Stat_t) if !ok { - return idtools.IDPair{}, errors.New("cannot convert stat value to syscall.Stat_t") + return idtools.Identity{}, errors.New("cannot convert stat value to syscall.Stat_t") } - return idtools.IDPair{UID: int(s.Uid), GID: int(s.Gid)}, nil + return idtools.Identity{UID: int(s.Uid), GID: int(s.Gid)}, nil } func chmodTarEntry(perm os.FileMode) os.FileMode { diff --git a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go index c14875cd77..c47768e68d 100644 --- a/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go +++ b/vendor/github.com/fsouza/go-dockerclient/internal/archive/archive_windows.go @@ -47,9 +47,9 @@ func getInodeFromStat(stat interface{}) (inode uint64, err error) { return } -func getFileUIDGID(stat interface{}) (idtools.IDPair, error) { +func getFileIdentity(stat interface{}) (idtools.Identity, error) { // no notion of file ownership mapping yet on Windows - return idtools.IDPair{0, 0}, nil + return idtools.Identity{}, nil } // chmodTarEntry is used to adjust the file permissions used in tar header based diff --git a/vendor/github.com/fsouza/go-dockerclient/network.go b/vendor/github.com/fsouza/go-dockerclient/network.go index c6ddb22c62..8c03b9ae6e 100644 --- a/vendor/github.com/fsouza/go-dockerclient/network.go +++ b/vendor/github.com/fsouza/go-dockerclient/network.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "net/http" + "net/url" ) // ErrNetworkAlreadyExists is the error returned by CreateNetwork when the @@ -71,7 +72,9 @@ func (c *Client) FilteredListNetworks(opts NetworkFilterOpts) ([]Network, error) if err != nil { return nil, err } - path := "/networks?filters=" + string(params) + qs := make(url.Values) + qs.Add("filters", string(params)) + path := "/networks?" + qs.Encode() resp, err := c.do("GET", path, doOptions{}) if err != nil { return nil, err diff --git a/vendor/github.com/fsouza/go-dockerclient/tls.go b/vendor/github.com/fsouza/go-dockerclient/tls.go index bb5790b5f0..5f0e2e31ee 100644 --- a/vendor/github.com/fsouza/go-dockerclient/tls.go +++ b/vendor/github.com/fsouza/go-dockerclient/tls.go @@ -109,10 +109,10 @@ func copyTLSConfig(cfg *tls.Config) *tls.Config { NameToCertificate: cfg.NameToCertificate, NextProtos: cfg.NextProtos, PreferServerCipherSuites: cfg.PreferServerCipherSuites, - Rand: cfg.Rand, - RootCAs: cfg.RootCAs, - ServerName: cfg.ServerName, - SessionTicketKey: cfg.SessionTicketKey, - SessionTicketsDisabled: cfg.SessionTicketsDisabled, + Rand: cfg.Rand, + RootCAs: cfg.RootCAs, + ServerName: cfg.ServerName, + SessionTicketKey: cfg.SessionTicketKey, + SessionTicketsDisabled: cfg.SessionTicketsDisabled, } } diff --git a/vendor/github.com/onsi/gomega/.gitignore b/vendor/github.com/onsi/gomega/.gitignore deleted file mode 100644 index 720c13cba8..0000000000 --- a/vendor/github.com/onsi/gomega/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.DS_Store -*.test -. -.idea -gomega.iml diff --git a/vendor/github.com/onsi/gomega/.travis.yml b/vendor/github.com/onsi/gomega/.travis.yml deleted file mode 100644 index 4d71367f6f..0000000000 --- a/vendor/github.com/onsi/gomega/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: go - -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - - 1.11.x - -env: - - GO111MODULE=on - -install: - - go get -v ./... - - go build ./... - - go get github.com/onsi/ginkgo - - go install github.com/onsi/ginkgo/ginkgo - -script: | - $HOME/gopath/bin/ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race && - go vet && - [ -z "`gofmt -l -e -s -w .`" ] diff --git a/vendor/github.com/onsi/gomega/CHANGELOG.md b/vendor/github.com/onsi/gomega/CHANGELOG.md deleted file mode 100644 index 9153294f75..0000000000 --- a/vendor/github.com/onsi/gomega/CHANGELOG.md +++ /dev/null @@ -1,125 +0,0 @@ -## 1.4.3 - -### Fixes: - -- ensure file name and line numbers are correctly reported for XUnit [6fff58f] -- Fixed matcher for content-type (#305) [69d9b43] - -## 1.4.2 - -### Fixes: - -- Add go.mod and go.sum files to define the gomega go module [f3de367, a085d30] -- Work around go vet issue with Go v1.11 (#300) [40dd6ad] -- Better output when using with go XUnit-style tests, fixes #255 (#297) [29a4b97] -- Fix MatchJSON fail to parse json.RawMessage (#298) [ae19f1b] -- show threshold in failure message of BeNumericallyMatcher (#293) [4bbecc8] - -## 1.4.1 - -### Fixes: - -- Update documentation formatting and examples (#289) [9be8410] -- allow 'Receive' matcher to be used with concrete types (#286) [41673fd] -- Fix data race in ghttp server (#283) [7ac6b01] -- Travis badge should only show master [cc102ab] - -## 1.4.0 - -### Features -- Make string pretty diff user configurable (#273) [eb112ce, 649b44d] - -### Fixes -- Use httputil.DumpRequest to pretty-print unhandled requests (#278) [a4ff0fc, b7d1a52] -- fix typo floa32 > float32 (#272) [041ae3b, 6e33911] -- Fix link to documentation on adding your own matchers (#270) [bb2c830, fcebc62] -- Use setters and getters to avoid race condition (#262) [13057c3, a9c79f1] -- Avoid sending a signal if the process is not alive (#259) [b8043e5, 4fc1762] -- Improve message from AssignableToTypeOf when expected value is nil (#281) [9c1fb20] - -## 1.3.0 - -Improvements: - -- The `Equal` matcher matches byte slices more performantly. -- Improved how `MatchError` matches error strings. -- `MatchXML` ignores the order of xml node attributes. -- Improve support for XUnit style golang tests. ([#254](https://github.com/onsi/gomega/issues/254)) - -Bug Fixes: - -- Diff generation now handles multi-byte sequences correctly. -- Multiple goroutines can now call `gexec.Build` concurrently. - -## 1.2.0 - -Improvements: - -- Added `BeSent` which attempts to send a value down a channel and fails if the attempt blocks. Can be paired with `Eventually` to safely send a value down a channel with a timeout. -- `Ω`, `Expect`, `Eventually`, and `Consistently` now immediately `panic` if there is no registered fail handler. This is always a mistake that can hide failing tests. -- `Receive()` no longer errors when passed a closed channel, it's perfectly fine to attempt to read from a closed channel so Ω(c).Should(Receive()) always fails and Ω(c).ShoudlNot(Receive()) always passes with a closed channel. -- Added `HavePrefix` and `HaveSuffix` matchers. -- `ghttp` can now handle concurrent requests. -- Added `Succeed` which allows one to write `Ω(MyFunction()).Should(Succeed())`. -- Improved `ghttp`'s behavior around failing assertions and panics: - - If a registered handler makes a failing assertion `ghttp` will return `500`. - - If a registered handler panics, `ghttp` will return `500` *and* fail the test. This is new behavior that may cause existing code to break. This code is almost certainly incorrect and creating a false positive. -- `ghttp` servers can take an `io.Writer`. `ghttp` will write a line to the writer when each request arrives. -- Added `WithTransform` matcher to allow munging input data before feeding into the relevant matcher -- Added boolean `And`, `Or`, and `Not` matchers to allow creating composite matchers -- Added `gbytes.TimeoutCloser`, `gbytes.TimeoutReader`, and `gbytes.TimeoutWriter` - these are convenience wrappers that timeout if the underlying Closer/Reader/Writer does not return within the alloted time. -- Added `gbytes.BufferReader` - this constructs a `gbytes.Buffer` that asynchronously reads the passed-in `io.Reader` into its buffer. - -Bug Fixes: -- gexec: `session.Wait` now uses `EventuallyWithOffset` to get the right line number in the failure. -- `ContainElement` no longer bails if a passed-in matcher errors. - -## 1.0 (8/2/2014) - -No changes. Dropping "beta" from the version number. - -## 1.0.0-beta (7/8/2014) -Breaking Changes: - -- Changed OmegaMatcher interface. Instead of having `Match` return failure messages, two new methods `FailureMessage` and `NegatedFailureMessage` are called instead. -- Moved and renamed OmegaFailHandler to types.GomegaFailHandler and OmegaMatcher to types.GomegaMatcher. Any references to OmegaMatcher in any custom matchers will need to be changed to point to types.GomegaMatcher - -New Test-Support Features: - -- `ghttp`: supports testing http clients - - Provides a flexible fake http server - - Provides a collection of chainable http handlers that perform assertions. -- `gbytes`: supports making ordered assertions against streams of data - - Provides a `gbytes.Buffer` - - Provides a `Say` matcher to perform ordered assertions against output data -- `gexec`: supports testing external processes - - Provides support for building Go binaries - - Wraps and starts `exec.Cmd` commands - - Makes it easy to assert against stdout and stderr - - Makes it easy to send signals and wait for processes to exit - - Provides an `Exit` matcher to assert against exit code. - -DSL Changes: - -- `Eventually` and `Consistently` can accept `time.Duration` interval and polling inputs. -- The default timeouts for `Eventually` and `Consistently` are now configurable. - -New Matchers: - -- `ConsistOf`: order-independent assertion against the elements of an array/slice or keys of a map. -- `BeTemporally`: like `BeNumerically` but for `time.Time` -- `HaveKeyWithValue`: asserts a map has a given key with the given value. - -Updated Matchers: - -- `Receive` matcher can take a matcher as an argument and passes only if the channel under test receives an objet that satisfies the passed-in matcher. -- Matchers that implement `MatchMayChangeInTheFuture(actual interface{}) bool` can inform `Eventually` and/or `Consistently` when a match has no chance of changing status in the future. For example, `Receive` returns `false` when a channel is closed. - -Misc: - -- Start using semantic versioning -- Start maintaining changelog - -Major refactor: - -- Pull out Gomega's internal to `internal` diff --git a/vendor/github.com/onsi/gomega/CONTRIBUTING.md b/vendor/github.com/onsi/gomega/CONTRIBUTING.md deleted file mode 100644 index 0d7a099289..0000000000 --- a/vendor/github.com/onsi/gomega/CONTRIBUTING.md +++ /dev/null @@ -1,14 +0,0 @@ -# Contributing to Gomega - -Your contributions to Gomega are essential for its long-term maintenance and improvement. To make a contribution: - -- Please **open an issue first** - describe what problem you are trying to solve and give the community a forum for input and feedback ahead of investing time in writing code! -- Ensure adequate test coverage: - - Make sure to add appropriate unit tests - - Please run all tests locally (`ginkgo -r -p`) and make sure they go green before submitting the PR - - Please run following linter locally `go vet ./...` and make sure output does not contain any warnings -- Update the documentation. In addition to standard `godoc` comments Gomega has extensive documentation on the `gh-pages` branch. If relevant, please submit a docs PR to that branch alongside your code PR. - -If you're a committer, check out RELEASING.md to learn how to cut a release. - -Thanks for supporting Gomega! diff --git a/vendor/github.com/onsi/gomega/RELEASING.md b/vendor/github.com/onsi/gomega/RELEASING.md deleted file mode 100644 index 998d64ee75..0000000000 --- a/vendor/github.com/onsi/gomega/RELEASING.md +++ /dev/null @@ -1,12 +0,0 @@ -A Gomega release is a tagged sha and a GitHub release. To cut a release: - -1. Ensure CHANGELOG.md is up to date. - - Use `git log --pretty=format:'- %s [%h]' HEAD...vX.X.X` to list all the commits since the last release - - Categorize the changes into - - Breaking Changes (requires a major version) - - New Features (minor version) - - Fixes (fix version) - - Maintenance (which in general should not be mentioned in `CHANGELOG.md` as they have no user impact) -2. Update GOMEGA_VERSION in `gomega_dsl.go` -3. Push a commit with the version number as the commit message (e.g. `v1.3.0`) -4. Create a new [GitHub release](https://help.github.com/articles/creating-releases/) with the version number as the tag (e.g. `v1.3.0`). List the key changes in the release notes. diff --git a/vendor/github.com/onsi/gomega/format/format_suite_test.go b/vendor/github.com/onsi/gomega/format/format_suite_test.go deleted file mode 100644 index 8e65a95292..0000000000 --- a/vendor/github.com/onsi/gomega/format/format_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package format_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestFormat(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Format Suite") -} diff --git a/vendor/github.com/onsi/gomega/format/format_test.go b/vendor/github.com/onsi/gomega/format/format_test.go deleted file mode 100644 index 9ea781379d..0000000000 --- a/vendor/github.com/onsi/gomega/format/format_test.go +++ /dev/null @@ -1,627 +0,0 @@ -package format_test - -import ( - "fmt" - "strings" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/format" - "github.com/onsi/gomega/types" -) - -//recursive struct - -type StringAlias string -type ByteAlias []byte -type IntAlias int - -type AStruct struct { - Exported string -} - -type SimpleStruct struct { - Name string - Enumeration int - Veritas bool - Data []byte - secret uint32 -} - -type ComplexStruct struct { - Strings []string - SimpleThings []*SimpleStruct - DataMaps map[int]ByteAlias -} - -type SecretiveStruct struct { - boolValue bool - intValue int - uintValue uint - uintptrValue uintptr - floatValue float32 - complexValue complex64 - chanValue chan bool - funcValue func() - pointerValue *int - sliceValue []string - byteSliceValue []byte - stringValue string - arrValue [3]int - byteArrValue [3]byte - mapValue map[string]int - structValue AStruct - interfaceValue interface{} -} - -type GoStringer struct { -} - -func (g GoStringer) GoString() string { - return "go-string" -} - -func (g GoStringer) String() string { - return "string" -} - -type Stringer struct { -} - -func (g Stringer) String() string { - return "string" -} - -type ctx struct { -} - -func (c *ctx) Deadline() (deadline time.Time, ok bool) { - return time.Time{}, false -} - -func (c *ctx) Done() <-chan struct{} { - return nil -} - -func (c *ctx) Err() error { - return nil -} - -func (c *ctx) Value(key interface{}) interface{} { - return nil -} - -var _ = Describe("Format", func() { - match := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher { - if len(args) > 0 { - valueRepresentation = fmt.Sprintf(valueRepresentation, args...) - } - return Equal(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation)) - } - - matchRegexp := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher { - if len(args) > 0 { - valueRepresentation = fmt.Sprintf(valueRepresentation, args...) - } - return MatchRegexp(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation)) - } - - hashMatchingRegexp := func(entries ...string) string { - entriesSwitch := "(" + strings.Join(entries, "|") + ")" - arr := make([]string, len(entries)) - for i := range arr { - arr[i] = entriesSwitch - } - return "{" + strings.Join(arr, ", ") + "}" - } - - Describe("Message", func() { - Context("with only an actual value", func() { - It("should print out an indented formatted representation of the value and the message", func() { - Expect(Message(3, "to be three.")).Should(Equal("Expected\n : 3\nto be three.")) - }) - }) - - Context("with an actual and an expected value", func() { - It("should print out an indented formatted representatino of both values, and the message", func() { - Expect(Message(3, "to equal", 4)).Should(Equal("Expected\n : 3\nto equal\n : 4")) - }) - }) - }) - - Describe("MessageWithDiff", func() { - It("shows the exact point where two long strings differ", func() { - stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedLongStringFailureMessage)) - }) - - It("truncates the start of long strings that differ only at their end", func() { - stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab" - stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz" - - Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedStartStringFailureMessage)) - }) - - It("truncates the start of long strings that differ only in length", func() { - smallString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - largeString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - Expect(MessageWithDiff(largeString, "to equal", smallString)).Should(Equal(expectedTruncatedStartSizeFailureMessage)) - Expect(MessageWithDiff(smallString, "to equal", largeString)).Should(Equal(expectedTruncatedStartSizeSwappedFailureMessage)) - }) - - It("truncates the end of long strings that differ only at their start", func() { - stringWithB := "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - stringWithZ := "zaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedEndStringFailureMessage)) - }) - - It("handles multi-byte sequences correctly", func() { - stringA := "• abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1" - stringB := "• abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" - - Expect(MessageWithDiff(stringA, "to equal", stringB)).Should(Equal(expectedTruncatedMultiByteFailureMessage)) - }) - - Context("With truncated diff disabled", func() { - BeforeEach(func() { - TruncatedDiff = false - }) - - AfterEach(func() { - TruncatedDiff = true - }) - - It("should show the full diff", func() { - stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedFullFailureDiff)) - }) - }) - }) - - Describe("IndentString", func() { - It("should indent the string", func() { - Expect(IndentString("foo\n bar\nbaz", 2)).Should(Equal(" foo\n bar\n baz")) - }) - }) - - Describe("Object", func() { - Describe("formatting boolean values", func() { - It("should give the type and format values correctly", func() { - Expect(Object(true, 1)).Should(match("bool", "true")) - Expect(Object(false, 1)).Should(match("bool", "false")) - }) - }) - - Describe("formatting numbers", func() { - It("should give the type and format values correctly", func() { - Expect(Object(int(3), 1)).Should(match("int", "3")) - Expect(Object(int8(3), 1)).Should(match("int8", "3")) - Expect(Object(int16(3), 1)).Should(match("int16", "3")) - Expect(Object(int32(3), 1)).Should(match("int32", "3")) - Expect(Object(int64(3), 1)).Should(match("int64", "3")) - - Expect(Object(uint(3), 1)).Should(match("uint", "3")) - Expect(Object(uint8(3), 1)).Should(match("uint8", "3")) - Expect(Object(uint16(3), 1)).Should(match("uint16", "3")) - Expect(Object(uint32(3), 1)).Should(match("uint32", "3")) - Expect(Object(uint64(3), 1)).Should(match("uint64", "3")) - }) - - It("should handle uintptr differently", func() { - Expect(Object(uintptr(3), 1)).Should(match("uintptr", "0x3")) - }) - }) - - Describe("formatting channels", func() { - It("should give the type and format values correctly", func() { - c := make(chan<- bool, 3) - c <- true - c <- false - Expect(Object(c, 1)).Should(match("chan<- bool | len:2, cap:3", "%v", c)) - }) - }) - - Describe("formatting strings", func() { - It("should give the type and format values correctly", func() { - s := "a\nb\nc" - Expect(Object(s, 1)).Should(match("string", `a - b - c`)) - }) - }) - - Describe("formatting []byte slices", func() { - Context("when the slice is made of printable bytes", func() { - It("should present it as string", func() { - b := []byte("a b c") - Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:5, cap:\d+`, `a b c`)) - }) - }) - Context("when the slice contains non-printable bytes", func() { - It("should present it as slice", func() { - b := []byte("a b c\n\x01\x02\x03\xff\x1bH") - Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:12, cap:\d+`, `\[97, 32, 98, 32, 99, 10, 1, 2, 3, 255, 27, 72\]`)) - }) - }) - }) - - Describe("formatting functions", func() { - It("should give the type and format values correctly", func() { - f := func(a string, b []int) ([]byte, error) { - return []byte("abc"), nil - } - Expect(Object(f, 1)).Should(match("func(string, []int) ([]uint8, error)", "%v", f)) - }) - }) - - Describe("formatting pointers", func() { - It("should give the type and dereference the value to format it correctly", func() { - a := 3 - Expect(Object(&a, 1)).Should(match(fmt.Sprintf("*int | %p", &a), "3")) - }) - - Context("when there are pointers to pointers...", func() { - It("should recursively deference the pointer until it gets to a value", func() { - a := 3 - var b *int - var c **int - var d ***int - b = &a - c = &b - d = &c - - Expect(Object(d, 1)).Should(match(fmt.Sprintf("***int | %p", d), "3")) - }) - }) - - Context("when the pointer points to nil", func() { - It("should say nil and not explode", func() { - var a *AStruct - Expect(Object(a, 1)).Should(match("*format_test.AStruct | 0x0", "nil")) - }) - }) - }) - - Describe("formatting arrays", func() { - It("should give the type and format values correctly", func() { - w := [3]string{"Jed Bartlet", "Toby Ziegler", "CJ Cregg"} - Expect(Object(w, 1)).Should(match("[3]string", `["Jed Bartlet", "Toby Ziegler", "CJ Cregg"]`)) - }) - - Context("with byte arrays", func() { - It("should give the type and format values correctly", func() { - w := [3]byte{17, 28, 19} - Expect(Object(w, 1)).Should(match("[3]uint8", `[17, 28, 19]`)) - }) - }) - }) - - Describe("formatting slices", func() { - It("should include the length and capacity in the type information", func() { - s := make([]bool, 3, 4) - Expect(Object(s, 1)).Should(match("[]bool | len:3, cap:4", "[false, false, false]")) - }) - - Context("when the slice contains long entries", func() { - It("should format the entries with newlines", func() { - w := []string{"Josiah Edward Bartlet", "Toby Ziegler", "CJ Cregg"} - expected := `[ - "Josiah Edward Bartlet", - "Toby Ziegler", - "CJ Cregg", - ]` - Expect(Object(w, 1)).Should(match("[]string | len:3, cap:3", expected)) - }) - }) - }) - - Describe("formatting maps", func() { - It("should include the length in the type information", func() { - m := make(map[int]bool, 5) - m[3] = true - m[4] = false - Expect(Object(m, 1)).Should(matchRegexp(`map\[int\]bool \| len:2`, hashMatchingRegexp("3: true", "4: false"))) - }) - - Context("when the slice contains long entries", func() { - It("should format the entries with newlines", func() { - m := map[string][]byte{} - m["Josiah Edward Bartlet"] = []byte("Martin Sheen") - m["Toby Ziegler"] = []byte("Richard Schiff") - m["CJ Cregg"] = []byte("Allison Janney") - expected := `{ - ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"), - ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"), - ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"), - }` - Expect(Object(m, 1)).Should(matchRegexp(`map\[string\]\[\]uint8 \| len:3`, expected)) - }) - }) - }) - - Describe("formatting structs", func() { - It("should include the struct name and the field names", func() { - s := SimpleStruct{ - Name: "Oswald", - Enumeration: 17, - Veritas: true, - Data: []byte("datum"), - secret: 1983, - } - - Expect(Object(s, 1)).Should(match("format_test.SimpleStruct", `{Name: "Oswald", Enumeration: 17, Veritas: true, Data: "datum", secret: 1983}`)) - }) - - Context("when the struct contains long entries", func() { - It("should format the entries with new lines", func() { - s := &SimpleStruct{ - Name: "Mithrandir Gandalf Greyhame", - Enumeration: 2021, - Veritas: true, - Data: []byte("wizard"), - secret: 3, - } - - Expect(Object(s, 1)).Should(match(fmt.Sprintf("*format_test.SimpleStruct | %p", s), `{ - Name: "Mithrandir Gandalf Greyhame", - Enumeration: 2021, - Veritas: true, - Data: "wizard", - secret: 3, - }`)) - }) - }) - }) - - Describe("formatting nil values", func() { - It("should print out nil", func() { - Expect(Object(nil, 1)).Should(match("nil", "nil")) - var typedNil *AStruct - Expect(Object(typedNil, 1)).Should(match("*format_test.AStruct | 0x0", "nil")) - var c chan<- bool - Expect(Object(c, 1)).Should(match("chan<- bool | len:0, cap:0", "nil")) - var s []string - Expect(Object(s, 1)).Should(match("[]string | len:0, cap:0", "nil")) - var m map[string]bool - Expect(Object(m, 1)).Should(match("map[string]bool | len:0", "nil")) - }) - }) - - Describe("formatting aliased types", func() { - It("should print out the correct alias type", func() { - Expect(Object(StringAlias("alias"), 1)).Should(match("format_test.StringAlias", `alias`)) - Expect(Object(ByteAlias("alias"), 1)).Should(matchRegexp(`format_test\.ByteAlias \| len:5, cap:\d+`, `alias`)) - Expect(Object(IntAlias(3), 1)).Should(match("format_test.IntAlias", "3")) - }) - }) - - Describe("handling nested things", func() { - It("should produce a correctly nested representation", func() { - s := ComplexStruct{ - Strings: []string{"lots", "of", "short", "strings"}, - SimpleThings: []*SimpleStruct{ - {"short", 7, true, []byte("succinct"), 17}, - {"something longer", 427, true, []byte("designed to wrap around nicely"), 30}, - }, - DataMaps: map[int]ByteAlias{ - 17: ByteAlias("some substantially longer chunks of data"), - 1138: ByteAlias("that should make things wrap"), - }, - } - expected := `{ - Strings: \["lots", "of", "short", "strings"\], - SimpleThings: \[ - {Name: "short", Enumeration: 7, Veritas: true, Data: "succinct", secret: 17}, - { - Name: "something longer", - Enumeration: 427, - Veritas: true, - Data: "designed to wrap around nicely", - secret: 30, - }, - \], - DataMaps: { - (17: "some substantially longer chunks of data"|1138: "that should make things wrap"), - (17: "some substantially longer chunks of data"|1138: "that should make things wrap"), - }, - }` - Expect(Object(s, 1)).Should(matchRegexp(`format_test\.ComplexStruct`, expected)) - }) - }) - - Describe("formatting times", func() { - It("should format time as RFC3339", func() { - t := time.Date(2016, 10, 31, 9, 57, 23, 12345, time.UTC) - Expect(Object(t, 1)).Should(match("time.Time", `2016-10-31T09:57:23.000012345Z`)) - }) - }) - }) - - Describe("Handling unexported fields in structs", func() { - It("should handle all the various types correctly", func() { - a := int(5) - s := SecretiveStruct{ - boolValue: true, - intValue: 3, - uintValue: 4, - uintptrValue: 5, - floatValue: 6.0, - complexValue: complex(5.0, 3.0), - chanValue: make(chan bool, 2), - funcValue: func() {}, - pointerValue: &a, - sliceValue: []string{"string", "slice"}, - byteSliceValue: []byte("bytes"), - stringValue: "a string", - arrValue: [3]int{11, 12, 13}, - byteArrValue: [3]byte{17, 20, 32}, - mapValue: map[string]int{"a key": 20, "b key": 30}, - structValue: AStruct{"exported"}, - interfaceValue: map[string]int{"a key": 17}, - } - - expected := fmt.Sprintf(`{ - boolValue: true, - intValue: 3, - uintValue: 4, - uintptrValue: 0x5, - floatValue: 6, - complexValue: \(5\+3i\), - chanValue: %p, - funcValue: %p, - pointerValue: 5, - sliceValue: \["string", "slice"\], - byteSliceValue: "bytes", - stringValue: "a string", - arrValue: \[11, 12, 13\], - byteArrValue: \[17, 20, 32\], - mapValue: %s, - structValue: {Exported: "exported"}, - interfaceValue: {"a key": 17}, - }`, s.chanValue, s.funcValue, hashMatchingRegexp(`"a key": 20`, `"b key": 30`)) - - Expect(Object(s, 1)).Should(matchRegexp(`format_test\.SecretiveStruct`, expected)) - }) - }) - - Describe("Handling interfaces", func() { - It("should unpack the interface", func() { - outerHash := map[string]interface{}{} - innerHash := map[string]int{} - - innerHash["inner"] = 3 - outerHash["integer"] = 2 - outerHash["map"] = innerHash - - expected := hashMatchingRegexp(`"integer": 2`, `"map": {"inner": 3}`) - Expect(Object(outerHash, 1)).Should(matchRegexp(`map\[string\]interface {} \| len:2`, expected)) - }) - }) - - Describe("Handling recursive things", func() { - It("should not go crazy...", func() { - m := map[string]interface{}{} - m["integer"] = 2 - m["map"] = m - Expect(Object(m, 1)).Should(ContainSubstring("...")) - }) - - It("really should not go crazy...", func() { - type complexKey struct { - Value map[interface{}]int - } - - complexObject := complexKey{} - complexObject.Value = make(map[interface{}]int) - - complexObject.Value[&complexObject] = 2 - Expect(Object(complexObject, 1)).Should(ContainSubstring("...")) - }) - }) - - Describe("When instructed to use the Stringer representation", func() { - BeforeEach(func() { - UseStringerRepresentation = true - }) - - AfterEach(func() { - UseStringerRepresentation = false - }) - - Context("when passed a GoStringer", func() { - It("should use what GoString() returns", func() { - Expect(Object(GoStringer{}, 1)).Should(ContainSubstring(": go-string")) - }) - }) - - Context("when passed a stringer", func() { - It("should use what String() returns", func() { - Expect(Object(Stringer{}, 1)).Should(ContainSubstring(": string")) - }) - }) - }) - - Describe("Printing a context.Context field", func() { - - type structWithContext struct { - Context Ctx - Value string - } - - context := ctx{} - objWithContext := structWithContext{Value: "some-value", Context: &context} - - It("Suppresses the content by default", func() { - Expect(Object(objWithContext, 1)).Should(ContainSubstring("")) - }) - - It("Doesn't supress the context if it's the object being printed", func() { - Expect(Object(context, 1)).ShouldNot(MatchRegexp("^.*$")) - }) - - Context("PrintContextObjects is set", func() { - BeforeEach(func() { - PrintContextObjects = true - }) - - AfterEach(func() { - PrintContextObjects = false - }) - - It("Prints the context", func() { - Expect(Object(objWithContext, 1)).ShouldNot(ContainSubstring("")) - }) - }) - }) -}) - -var expectedLongStringFailureMessage = strings.TrimSpace(` -Expected - : "...aaaaabaaaaa..." -to equal | - : "...aaaaazaaaaa..." -`) -var expectedTruncatedEndStringFailureMessage = strings.TrimSpace(` -Expected - : "baaaaa..." -to equal | - : "zaaaaa..." -`) -var expectedTruncatedStartStringFailureMessage = strings.TrimSpace(` -Expected - : "...aaaaab" -to equal | - : "...aaaaaz" -`) -var expectedTruncatedStartSizeFailureMessage = strings.TrimSpace(` -Expected - : "...aaaaaa" -to equal | - : "...aaaaa" -`) -var expectedTruncatedStartSizeSwappedFailureMessage = strings.TrimSpace(` -Expected - : "...aaaa" -to equal | - : "...aaaaa" -`) -var expectedTruncatedMultiByteFailureMessage = strings.TrimSpace(` -Expected - : "...tuvwxyz1" -to equal | - : "...tuvwxyz" -`) - -var expectedFullFailureDiff = strings.TrimSpace(` -Expected - : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -to equal - : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -`) diff --git a/vendor/github.com/onsi/gomega/gbytes/buffer_test.go b/vendor/github.com/onsi/gomega/gbytes/buffer_test.go deleted file mode 100644 index 9d4e8279de..0000000000 --- a/vendor/github.com/onsi/gomega/gbytes/buffer_test.go +++ /dev/null @@ -1,205 +0,0 @@ -package gbytes_test - -import ( - "io" - "time" - - . "github.com/onsi/gomega/gbytes" - - "bytes" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type SlowReader struct { - R io.Reader - D time.Duration -} - -func (s SlowReader) Read(p []byte) (int, error) { - time.Sleep(s.D) - return s.R.Read(p) -} - -var _ = Describe("Buffer", func() { - var buffer *Buffer - - BeforeEach(func() { - buffer = NewBuffer() - }) - - Describe("dumping the entire contents of the buffer", func() { - It("should return everything that's been written", func() { - buffer.Write([]byte("abc")) - buffer.Write([]byte("def")) - Expect(buffer.Contents()).Should(Equal([]byte("abcdef"))) - - Expect(buffer).Should(Say("bcd")) - Expect(buffer.Contents()).Should(Equal([]byte("abcdef"))) - }) - }) - - Describe("creating a buffer with bytes", func() { - It("should create the buffer with the cursor set to the beginning", func() { - buffer := BufferWithBytes([]byte("abcdef")) - Expect(buffer.Contents()).Should(Equal([]byte("abcdef"))) - Expect(buffer).Should(Say("abc")) - Expect(buffer).ShouldNot(Say("abc")) - Expect(buffer).Should(Say("def")) - }) - }) - - Describe("creating a buffer that wraps a reader", func() { - Context("for a well-behaved reader", func() { - It("should buffer the contents of the reader", func() { - reader := bytes.NewBuffer([]byte("abcdef")) - buffer := BufferReader(reader) - Eventually(buffer).Should(Say("abc")) - Expect(buffer).ShouldNot(Say("abc")) - Eventually(buffer).Should(Say("def")) - Eventually(buffer.Closed).Should(BeTrue()) - }) - }) - - Context("for a slow reader", func() { - It("should allow Eventually to time out", func() { - slowReader := SlowReader{ - R: bytes.NewBuffer([]byte("abcdef")), - D: time.Second, - } - buffer := BufferReader(slowReader) - failures := InterceptGomegaFailures(func() { - Eventually(buffer, 100*time.Millisecond).Should(Say("abc")) - }) - Expect(failures).ShouldNot(BeEmpty()) - - fastReader := SlowReader{ - R: bytes.NewBuffer([]byte("abcdef")), - D: time.Millisecond, - } - buffer = BufferReader(fastReader) - Eventually(buffer, 100*time.Millisecond).Should(Say("abc")) - Eventually(buffer.Closed).Should(BeTrue()) - }) - }) - }) - - Describe("reading from a buffer", func() { - It("should read the current contents of the buffer", func() { - buffer := BufferWithBytes([]byte("abcde")) - - dest := make([]byte, 3) - n, err := buffer.Read(dest) - Expect(err).ShouldNot(HaveOccurred()) - Expect(n).Should(Equal(3)) - Expect(string(dest)).Should(Equal("abc")) - - dest = make([]byte, 3) - n, err = buffer.Read(dest) - Expect(err).ShouldNot(HaveOccurred()) - Expect(n).Should(Equal(2)) - Expect(string(dest[:n])).Should(Equal("de")) - - n, err = buffer.Read(dest) - Expect(err).Should(Equal(io.EOF)) - Expect(n).Should(Equal(0)) - }) - - Context("after the buffer has been closed", func() { - It("returns an error", func() { - buffer := BufferWithBytes([]byte("abcde")) - - buffer.Close() - - dest := make([]byte, 3) - n, err := buffer.Read(dest) - Expect(err).Should(HaveOccurred()) - Expect(n).Should(Equal(0)) - }) - }) - }) - - Describe("detecting regular expressions", func() { - It("should fire the appropriate channel when the passed in pattern matches, then close it", func(done Done) { - go func() { - time.Sleep(10 * time.Millisecond) - buffer.Write([]byte("abcde")) - }() - - A := buffer.Detect("%s", "a.c") - B := buffer.Detect("def") - - var gotIt bool - select { - case gotIt = <-A: - case <-B: - Fail("should not have gotten here") - } - - Expect(gotIt).Should(BeTrue()) - Eventually(A).Should(BeClosed()) - - buffer.Write([]byte("f")) - Eventually(B).Should(Receive()) - Eventually(B).Should(BeClosed()) - - close(done) - }) - - It("should fast-forward the buffer upon detection", func(done Done) { - buffer.Write([]byte("abcde")) - <-buffer.Detect("abc") - Expect(buffer).ShouldNot(Say("abc")) - Expect(buffer).Should(Say("de")) - close(done) - }) - - It("should only fast-forward the buffer when the channel is read, and only if doing so would not rewind it", func(done Done) { - buffer.Write([]byte("abcde")) - A := buffer.Detect("abc") - time.Sleep(20 * time.Millisecond) //give the goroutine a chance to detect and write to the channel - Expect(buffer).Should(Say("abcd")) - <-A - Expect(buffer).ShouldNot(Say("d")) - Expect(buffer).Should(Say("e")) - Eventually(A).Should(BeClosed()) - close(done) - }) - - It("should be possible to cancel a detection", func(done Done) { - A := buffer.Detect("abc") - B := buffer.Detect("def") - buffer.CancelDetects() - buffer.Write([]byte("abcdef")) - Eventually(A).Should(BeClosed()) - Eventually(B).Should(BeClosed()) - - Expect(buffer).Should(Say("bcde")) - <-buffer.Detect("f") - close(done) - }) - }) - - Describe("closing the buffer", func() { - It("should error when further write attempts are made", func() { - _, err := buffer.Write([]byte("abc")) - Expect(err).ShouldNot(HaveOccurred()) - - buffer.Close() - - _, err = buffer.Write([]byte("def")) - Expect(err).Should(HaveOccurred()) - - Expect(buffer.Contents()).Should(Equal([]byte("abc"))) - }) - - It("should be closed", func() { - Expect(buffer.Closed()).Should(BeFalse()) - - buffer.Close() - - Expect(buffer.Closed()).Should(BeTrue()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go b/vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go deleted file mode 100644 index 3a7dc06123..0000000000 --- a/vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package gbytes_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestGbytes(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Gbytes Suite") -} diff --git a/vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go b/vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go deleted file mode 100644 index 3da9734982..0000000000 --- a/vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go +++ /dev/null @@ -1,188 +0,0 @@ -package gbytes_test - -import ( - "fmt" - "io" - "time" - - . "github.com/onsi/gomega/gbytes" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type FakeCloser struct { - err error - duration time.Duration -} - -func (f FakeCloser) Close() error { - time.Sleep(f.duration) - return f.err -} - -type FakeReader struct { - err error - duration time.Duration -} - -func (f FakeReader) Read(p []byte) (int, error) { - time.Sleep(f.duration) - if f.err != nil { - return 0, f.err - } - - for i := 0; i < len(p); i++ { - p[i] = 'a' - } - - return len(p), nil -} - -type FakeWriter struct { - err error - duration time.Duration -} - -func (f FakeWriter) Write(p []byte) (int, error) { - time.Sleep(f.duration) - if f.err != nil { - return 0, f.err - } - - return len(p), nil -} - -var _ = Describe("Io Wrappers", func() { - Describe("TimeoutCloser", func() { - var innerCloser io.Closer - var timeoutCloser io.Closer - - JustBeforeEach(func() { - timeoutCloser = TimeoutCloser(innerCloser, 20*time.Millisecond) - }) - - Context("when the underlying Closer closes with no error", func() { - BeforeEach(func() { - innerCloser = FakeCloser{} - }) - - It("returns with no error", func() { - Expect(timeoutCloser.Close()).Should(Succeed()) - }) - }) - - Context("when the underlying Closer closes with an error", func() { - BeforeEach(func() { - innerCloser = FakeCloser{err: fmt.Errorf("boom")} - }) - - It("returns the error", func() { - Expect(timeoutCloser.Close()).Should(MatchError("boom")) - }) - }) - - Context("when the underlying Closer hangs", func() { - BeforeEach(func() { - innerCloser = FakeCloser{ - err: fmt.Errorf("boom"), - duration: time.Hour, - } - }) - - It("returns ErrTimeout", func() { - Expect(timeoutCloser.Close()).Should(MatchError(ErrTimeout)) - }) - }) - }) - - Describe("TimeoutReader", func() { - var innerReader io.Reader - var timeoutReader io.Reader - - JustBeforeEach(func() { - timeoutReader = TimeoutReader(innerReader, 20*time.Millisecond) - }) - - Context("when the underlying Reader returns no error", func() { - BeforeEach(func() { - innerReader = FakeReader{} - }) - - It("returns with no error", func() { - p := make([]byte, 5) - n, err := timeoutReader.Read(p) - Expect(n).Should(Equal(5)) - Expect(err).ShouldNot(HaveOccurred()) - Expect(p).Should(Equal([]byte("aaaaa"))) - }) - }) - - Context("when the underlying Reader returns an error", func() { - BeforeEach(func() { - innerReader = FakeReader{err: fmt.Errorf("boom")} - }) - - It("returns the error", func() { - p := make([]byte, 5) - _, err := timeoutReader.Read(p) - Expect(err).Should(MatchError("boom")) - }) - }) - - Context("when the underlying Reader hangs", func() { - BeforeEach(func() { - innerReader = FakeReader{err: fmt.Errorf("boom"), duration: time.Hour} - }) - - It("returns ErrTimeout", func() { - p := make([]byte, 5) - _, err := timeoutReader.Read(p) - Expect(err).Should(MatchError(ErrTimeout)) - }) - }) - }) - - Describe("TimeoutWriter", func() { - var innerWriter io.Writer - var timeoutWriter io.Writer - - JustBeforeEach(func() { - timeoutWriter = TimeoutWriter(innerWriter, 20*time.Millisecond) - }) - - Context("when the underlying Writer returns no error", func() { - BeforeEach(func() { - innerWriter = FakeWriter{} - }) - - It("returns with no error", func() { - n, err := timeoutWriter.Write([]byte("aaaaa")) - Expect(n).Should(Equal(5)) - Expect(err).ShouldNot(HaveOccurred()) - }) - }) - - Context("when the underlying Writer returns an error", func() { - BeforeEach(func() { - innerWriter = FakeWriter{err: fmt.Errorf("boom")} - }) - - It("returns the error", func() { - _, err := timeoutWriter.Write([]byte("aaaaa")) - Expect(err).Should(MatchError("boom")) - }) - }) - - Context("when the underlying Writer hangs", func() { - BeforeEach(func() { - innerWriter = FakeWriter{err: fmt.Errorf("boom"), duration: time.Hour} - }) - - It("returns ErrTimeout", func() { - _, err := timeoutWriter.Write([]byte("aaaaa")) - Expect(err).Should(MatchError(ErrTimeout)) - }) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go b/vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go deleted file mode 100644 index 0055d4a1bd..0000000000 --- a/vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go +++ /dev/null @@ -1,169 +0,0 @@ -package gbytes_test - -import ( - "time" - - . "github.com/onsi/gomega/gbytes" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type speaker struct { - buffer *Buffer -} - -func (s *speaker) Buffer() *Buffer { - return s.buffer -} - -var _ = Describe("SayMatcher", func() { - var buffer *Buffer - - BeforeEach(func() { - buffer = NewBuffer() - buffer.Write([]byte("abc")) - }) - - Context("when actual is not a gexec Buffer, or a BufferProvider", func() { - It("should error", func() { - failures := InterceptGomegaFailures(func() { - Expect("foo").Should(Say("foo")) - }) - Expect(failures[0]).Should(ContainSubstring("*gbytes.Buffer")) - }) - }) - - Context("when a match is found", func() { - It("should succeed", func() { - Expect(buffer).Should(Say("abc")) - }) - - It("should support printf-like formatting", func() { - Expect(buffer).Should(Say("a%sc", "b")) - }) - - It("should match literal %", func() { - buffer.Write([]byte("%")) - Expect(buffer).Should(Say("abc%")) - }) - - It("should use a regular expression", func() { - Expect(buffer).Should(Say("a.c")) - }) - - It("should fastforward the buffer", func() { - buffer.Write([]byte("def")) - Expect(buffer).Should(Say("abcd")) - Expect(buffer).Should(Say("ef")) - Expect(buffer).ShouldNot(Say("[a-z]")) - }) - }) - - Context("when no match is found", func() { - It("should not error", func() { - Expect(buffer).ShouldNot(Say("def")) - }) - - Context("when the buffer is closed", func() { - BeforeEach(func() { - buffer.Close() - }) - - It("should abort an eventually", func() { - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(buffer).Should(Say("def")) - }) - Eventually(buffer).ShouldNot(Say("def")) - Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond)) - Expect(failures).Should(HaveLen(1)) - - t = time.Now() - Eventually(buffer).Should(Say("abc")) - Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond)) - }) - - It("should abort a consistently", func() { - t := time.Now() - Consistently(buffer, 2.0).ShouldNot(Say("def")) - Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond)) - }) - - It("should not error with a synchronous matcher", func() { - Expect(buffer).ShouldNot(Say("def")) - Expect(buffer).Should(Say("abc")) - }) - }) - }) - - Context("when a positive match fails", func() { - It("should report where it got stuck", func() { - Expect(buffer).Should(Say("abc")) - buffer.Write([]byte("def")) - failures := InterceptGomegaFailures(func() { - Expect(buffer).Should(Say("abc")) - }) - Expect(failures[0]).Should(ContainSubstring("Got stuck at:")) - Expect(failures[0]).Should(ContainSubstring("def")) - }) - }) - - Context("when a negative match fails", func() { - It("should report where it got stuck", func() { - failures := InterceptGomegaFailures(func() { - Expect(buffer).ShouldNot(Say("abc")) - }) - Expect(failures[0]).Should(ContainSubstring("Saw:")) - Expect(failures[0]).Should(ContainSubstring("Which matches the unexpected:")) - Expect(failures[0]).Should(ContainSubstring("abc")) - }) - }) - - Context("when a match is not found", func() { - It("should not fastforward the buffer", func() { - Expect(buffer).ShouldNot(Say("def")) - Expect(buffer).Should(Say("abc")) - }) - }) - - Context("a nice real-life example", func() { - It("should behave well", func() { - Expect(buffer).Should(Say("abc")) - go func() { - time.Sleep(10 * time.Millisecond) - buffer.Write([]byte("def")) - }() - Expect(buffer).ShouldNot(Say("def")) - Eventually(buffer).Should(Say("def")) - }) - }) - - Context("when actual is a BufferProvider", func() { - It("should use actual's buffer", func() { - s := &speaker{ - buffer: NewBuffer(), - } - - Expect(s).ShouldNot(Say("abc")) - - s.Buffer().Write([]byte("abc")) - Expect(s).Should(Say("abc")) - }) - - It("should abort an eventually", func() { - s := &speaker{ - buffer: NewBuffer(), - } - - s.buffer.Close() - - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(s).Should(Say("def")) - }) - Expect(failures).Should(HaveLen(1)) - Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond)) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go b/vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go deleted file mode 100644 index 16091c22b1..0000000000 --- a/vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "fmt" - "math/rand" - "os" - "strconv" - "time" -) - -var outQuote = "We've done the impossible, and that makes us mighty." -var errQuote = "Ah, curse your sudden but inevitable betrayal!" - -var randomQuotes = []string{ - "Can we maybe vote on the whole murdering people issue?", - "I swear by my pretty floral bonnet, I will end you.", - "My work's illegal, but at least it's honest.", -} - -func main() { - fmt.Fprintln(os.Stdout, outQuote) - fmt.Fprintln(os.Stderr, errQuote) - - randomIndex := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(len(randomQuotes)) - - time.Sleep(100 * time.Millisecond) - - fmt.Fprintln(os.Stdout, randomQuotes[randomIndex]) - - if len(os.Args) == 2 { - exitCode, _ := strconv.Atoi(os.Args[1]) - os.Exit(exitCode) - } else { - os.Exit(randomIndex) - } -} diff --git a/vendor/github.com/onsi/gomega/gexec/build_test.go b/vendor/github.com/onsi/gomega/gexec/build_test.go deleted file mode 100644 index 295dac8bcd..0000000000 --- a/vendor/github.com/onsi/gomega/gexec/build_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package gexec_test - -import ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/gexec" -) - -var packagePath = "./_fixture/firefly" - -var _ = Describe(".Build", func() { - Context("when there have been previous calls to Build", func() { - BeforeEach(func() { - _, err := gexec.Build(packagePath) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("compiles the specified package", func() { - compiledPath, err := gexec.Build(packagePath) - Expect(err).ShouldNot(HaveOccurred()) - Expect(compiledPath).Should(BeAnExistingFile()) - }) - - Context("and CleanupBuildArtifacts has been called", func() { - BeforeEach(func() { - gexec.CleanupBuildArtifacts() - }) - - It("compiles the specified package", func() { - var err error - fireflyPath, err = gexec.Build(packagePath) - Expect(err).ShouldNot(HaveOccurred()) - Expect(fireflyPath).Should(BeAnExistingFile()) - }) - }) - }) -}) - -var _ = Describe(".BuildWithEnvironment", func() { - var err error - env := []string{ - "GOOS=linux", - "GOARCH=amd64", - } - - It("compiles the specified package with the specified env vars", func() { - compiledPath, err := gexec.BuildWithEnvironment(packagePath, env) - Expect(err).ShouldNot(HaveOccurred()) - Expect(compiledPath).Should(BeAnExistingFile()) - }) - - It("returns the environment to a good state", func() { - _, err = gexec.BuildWithEnvironment(packagePath, env) - Expect(err).ShouldNot(HaveOccurred()) - Expect(os.Environ()).ShouldNot(ContainElement("GOOS=linux")) - }) -}) - -var _ = Describe(".BuildIn", func() { - const ( - target = "github.com/onsi/gomega/gexec/_fixture/firefly/" - ) - - var ( - original string - gopath string - ) - - BeforeEach(func() { - var err error - original = os.Getenv("GOPATH") - gopath, err = ioutil.TempDir("", "") - Expect(err).NotTo(HaveOccurred()) - copyFile(filepath.Join("_fixture", "firefly", "main.go"), filepath.Join(gopath, "src", target), "main.go") - Expect(os.Setenv("GOPATH", filepath.Join(os.TempDir(), "emptyFakeGopath"))).To(Succeed()) - Expect(os.Environ()).To(ContainElement(fmt.Sprintf("GOPATH=%s", filepath.Join(os.TempDir(), "emptyFakeGopath")))) - }) - - AfterEach(func() { - if original == "" { - Expect(os.Unsetenv("GOPATH")).To(Succeed()) - } else { - Expect(os.Setenv("GOPATH", original)).To(Succeed()) - } - if gopath != "" { - os.RemoveAll(gopath) - } - }) - - It("appends the gopath env var", func() { - _, err := gexec.BuildIn(gopath, target) - Expect(err).NotTo(HaveOccurred()) - }) - - It("resets GOPATH to its original value", func() { - _, err := gexec.BuildIn(gopath, target) - Expect(err).NotTo(HaveOccurred()) - Expect(os.Getenv("GOPATH")).To(Equal(filepath.Join(os.TempDir(), "emptyFakeGopath"))) - }) -}) - -func copyFile(source, directory, basename string) { - Expect(os.MkdirAll(directory, 0755)).To(Succeed()) - content, err := ioutil.ReadFile(source) - Expect(err).NotTo(HaveOccurred()) - Expect(ioutil.WriteFile(filepath.Join(directory, basename), content, 0644)).To(Succeed()) -} diff --git a/vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go b/vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go deleted file mode 100644 index 9abc3226f6..0000000000 --- a/vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go +++ /dev/null @@ -1,114 +0,0 @@ -package gexec_test - -import ( - "os/exec" - "time" - - . "github.com/onsi/gomega/gexec" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type NeverExits struct{} - -func (e NeverExits) ExitCode() int { - return -1 -} - -var _ = Describe("ExitMatcher", func() { - var command *exec.Cmd - var session *Session - - BeforeEach(func() { - var err error - command = exec.Command(fireflyPath, "0") - session, err = Start(command, nil, nil) - Expect(err).ShouldNot(HaveOccurred()) - }) - - Describe("when passed something that is an Exiter", func() { - It("should act normally", func() { - failures := InterceptGomegaFailures(func() { - Expect(NeverExits{}).Should(Exit()) - }) - - Expect(failures[0]).Should(ContainSubstring("Expected process to exit. It did not.")) - }) - }) - - Describe("when passed something that is not an Exiter", func() { - It("should error", func() { - failures := InterceptGomegaFailures(func() { - Expect("aardvark").Should(Exit()) - }) - - Expect(failures[0]).Should(ContainSubstring("Exit must be passed a gexec.Exiter")) - }) - }) - - Context("with no exit code", func() { - It("should say the right things when it fails", func() { - Expect(session).ShouldNot(Exit()) - - failures := InterceptGomegaFailures(func() { - Expect(session).Should(Exit()) - }) - - Expect(failures[0]).Should(ContainSubstring("Expected process to exit. It did not.")) - - Eventually(session).Should(Exit()) - - Expect(session).Should(Exit()) - - failures = InterceptGomegaFailures(func() { - Expect(session).ShouldNot(Exit()) - }) - - Expect(failures[0]).Should(ContainSubstring("Expected process not to exit. It did.")) - }) - }) - - Context("with an exit code", func() { - It("should say the right things when it fails", func() { - Expect(session).ShouldNot(Exit(0)) - Expect(session).ShouldNot(Exit(1)) - - failures := InterceptGomegaFailures(func() { - Expect(session).Should(Exit(0)) - }) - - Expect(failures[0]).Should(ContainSubstring("Expected process to exit. It did not.")) - - Eventually(session).Should(Exit(0)) - - Expect(session).Should(Exit(0)) - - failures = InterceptGomegaFailures(func() { - Expect(session).Should(Exit(1)) - }) - - Expect(failures[0]).Should(ContainSubstring("to match exit code:")) - - Expect(session).ShouldNot(Exit(1)) - - failures = InterceptGomegaFailures(func() { - Expect(session).ShouldNot(Exit(0)) - }) - - Expect(failures[0]).Should(ContainSubstring("not to match exit code:")) - }) - }) - - Describe("bailing out early", func() { - It("should bail out early once the process exits", func() { - t := time.Now() - - failures := InterceptGomegaFailures(func() { - Eventually(session).Should(Exit(1)) - }) - Expect(time.Since(t)).Should(BeNumerically("<=", 500*time.Millisecond)) - Expect(failures).Should(HaveLen(1)) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go b/vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go deleted file mode 100644 index dc8e1f40ce..0000000000 --- a/vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package gexec_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/gexec" - - "testing" -) - -var fireflyPath string - -func TestGexec(t *testing.T) { - BeforeSuite(func() { - var err error - fireflyPath, err = gexec.Build("./_fixture/firefly") - Expect(err).ShouldNot(HaveOccurred()) - }) - - AfterSuite(func() { - gexec.CleanupBuildArtifacts() - }) - - RegisterFailHandler(Fail) - RunSpecs(t, "Gexec Suite") -} diff --git a/vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go b/vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go deleted file mode 100644 index e847b15019..0000000000 --- a/vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go +++ /dev/null @@ -1,43 +0,0 @@ -package gexec_test - -import ( - "bytes" - - . "github.com/onsi/gomega/gexec" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("PrefixedWriter", func() { - var buffer *bytes.Buffer - var writer *PrefixedWriter - BeforeEach(func() { - buffer = &bytes.Buffer{} - writer = NewPrefixedWriter("[p]", buffer) - }) - - It("should emit the prefix on newlines", func() { - writer.Write([]byte("abc")) - writer.Write([]byte("def\n")) - writer.Write([]byte("hij\n")) - writer.Write([]byte("\n\n")) - writer.Write([]byte("klm\n\nnop")) - writer.Write([]byte("")) - writer.Write([]byte("qrs")) - writer.Write([]byte("\ntuv\nwx")) - writer.Write([]byte("yz\n\n")) - - Expect(buffer.String()).Should(Equal(`[p]abcdef -[p]hij -[p] -[p] -[p]klm -[p] -[p]nopqrs -[p]tuv -[p]wxyz -[p] -`)) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gexec/session_test.go b/vendor/github.com/onsi/gomega/gexec/session_test.go deleted file mode 100644 index 6fdf22d213..0000000000 --- a/vendor/github.com/onsi/gomega/gexec/session_test.go +++ /dev/null @@ -1,336 +0,0 @@ -package gexec_test - -import ( - "io" - "io/ioutil" - "os/exec" - "syscall" - "time" - - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Session", func() { - var command *exec.Cmd - var session *Session - - var outWriter, errWriter io.Writer - - BeforeEach(func() { - outWriter = nil - errWriter = nil - }) - - JustBeforeEach(func() { - command = exec.Command(fireflyPath) - var err error - session, err = Start(command, outWriter, errWriter) - Expect(err).ShouldNot(HaveOccurred()) - }) - - Context("running a command", func() { - It("should start the process", func() { - Expect(command.Process).ShouldNot(BeNil()) - }) - - It("should wrap the process's stdout and stderr with gbytes buffers", func(done Done) { - Eventually(session.Out).Should(Say("We've done the impossible, and that makes us mighty")) - Eventually(session.Err).Should(Say("Ah, curse your sudden but inevitable betrayal!")) - defer session.Out.CancelDetects() - - select { - case <-session.Out.Detect("Can we maybe vote on the whole murdering people issue"): - Eventually(session).Should(Exit(0)) - case <-session.Out.Detect("I swear by my pretty floral bonnet, I will end you."): - Eventually(session).Should(Exit(1)) - case <-session.Out.Detect("My work's illegal, but at least it's honest."): - Eventually(session).Should(Exit(2)) - } - - close(done) - }) - - It("should satisfy the gbytes.BufferProvider interface, passing Stdout", func() { - Eventually(session).Should(Say("We've done the impossible, and that makes us mighty")) - Eventually(session).Should(Exit()) - }) - }) - - Describe("providing the exit code", func() { - It("should provide the app's exit code", func() { - Expect(session.ExitCode()).Should(Equal(-1)) - - Eventually(session).Should(Exit()) - Expect(session.ExitCode()).Should(BeNumerically(">=", 0)) - Expect(session.ExitCode()).Should(BeNumerically("<", 3)) - }) - }) - - Describe("wait", func() { - It("should wait till the command exits", func() { - Expect(session.ExitCode()).Should(Equal(-1)) - Expect(session.Wait().ExitCode()).Should(BeNumerically(">=", 0)) - Expect(session.Wait().ExitCode()).Should(BeNumerically("<", 3)) - }) - }) - - Describe("exited", func() { - It("should close when the command exits", func() { - Eventually(session.Exited).Should(BeClosed()) - Expect(session.ExitCode()).ShouldNot(Equal(-1)) - }) - }) - - Describe("kill", func() { - It("should kill the command", func() { - session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session.Kill() - Eventually(session).Should(Exit(128 + 9)) - }) - }) - - Describe("interrupt", func() { - It("should interrupt the command", func() { - session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session.Interrupt() - Eventually(session).Should(Exit(128 + 2)) - }) - }) - - Describe("terminate", func() { - It("should terminate the command", func() { - session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session.Terminate() - Eventually(session).Should(Exit(128 + 15)) - }) - }) - - Describe("signal", func() { - It("should send the signal to the command", func() { - session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session.Signal(syscall.SIGABRT) - Eventually(session).Should(Exit(128 + 6)) - }) - - It("should ignore sending a signal if the command did not start", func() { - session, err := Start(exec.Command("notexisting"), GinkgoWriter, GinkgoWriter) - Expect(err).To(HaveOccurred()) - - Expect(func() { session.Signal(syscall.SIGUSR1) }).NotTo(Panic()) - }) - }) - - Context("tracking sessions", func() { - BeforeEach(func() { - KillAndWait() - }) - - Describe("kill", func() { - It("should kill all the started sessions", func() { - session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - Kill() - - Eventually(session1).Should(Exit(128 + 9)) - Eventually(session2).Should(Exit(128 + 9)) - Eventually(session3).Should(Exit(128 + 9)) - }) - - It("should not track unstarted sessions", func() { - _, err := Start(exec.Command("does not exist", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).Should(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - Kill() - - Eventually(session2).Should(Exit(128 + 9)) - Eventually(session3).Should(Exit(128 + 9)) - }) - - }) - - Describe("killAndWait", func() { - It("should kill all the started sessions and wait for them to finish", func() { - session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - KillAndWait() - Expect(session1).Should(Exit(128+9), "Should have exited") - Expect(session2).Should(Exit(128+9), "Should have exited") - Expect(session3).Should(Exit(128+9), "Should have exited") - }) - }) - - Describe("terminate", func() { - It("should terminate all the started sessions", func() { - session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - Terminate() - - Eventually(session1).Should(Exit(128 + 15)) - Eventually(session2).Should(Exit(128 + 15)) - Eventually(session3).Should(Exit(128 + 15)) - }) - }) - - Describe("terminateAndWait", func() { - It("should terminate all the started sessions, and wait for them to exit", func() { - session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - TerminateAndWait() - - Expect(session1).Should(Exit(128+15), "Should have exited") - Expect(session2).Should(Exit(128+15), "Should have exited") - Expect(session3).Should(Exit(128+15), "Should have exited") - }) - }) - - Describe("signal", func() { - It("should signal all the started sessions", func() { - session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - Signal(syscall.SIGABRT) - - Eventually(session1).Should(Exit(128 + 6)) - Eventually(session2).Should(Exit(128 + 6)) - Eventually(session3).Should(Exit(128 + 6)) - }) - }) - - Describe("interrupt", func() { - It("should interrupt all the started sessions, and not wait", func() { - session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) - Expect(err).ShouldNot(HaveOccurred()) - - Interrupt() - - Eventually(session1).Should(Exit(128 + 2)) - Eventually(session2).Should(Exit(128 + 2)) - Eventually(session3).Should(Exit(128 + 2)) - }) - }) - }) - - Context("when the command exits", func() { - It("should close the buffers", func() { - Eventually(session).Should(Exit()) - - Expect(session.Out.Closed()).Should(BeTrue()) - Expect(session.Err.Closed()).Should(BeTrue()) - - Expect(session.Out).Should(Say("We've done the impossible, and that makes us mighty")) - }) - - var So = It - - So("this means that eventually should short circuit", func() { - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(session).Should(Say("blah blah blah blah blah")) - }) - Expect(time.Since(t)).Should(BeNumerically("<=", 500*time.Millisecond)) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Context("when wrapping out and err", func() { - var ( - outWriterBuffer, errWriterBuffer *Buffer - ) - - BeforeEach(func() { - outWriterBuffer = NewBuffer() - outWriter = outWriterBuffer - errWriterBuffer = NewBuffer() - errWriter = errWriterBuffer - }) - - It("should route to both the provided writers and the gbytes buffers", func() { - Eventually(session.Out).Should(Say("We've done the impossible, and that makes us mighty")) - Eventually(session.Err).Should(Say("Ah, curse your sudden but inevitable betrayal!")) - - Expect(outWriterBuffer.Contents()).Should(ContainSubstring("We've done the impossible, and that makes us mighty")) - Expect(errWriterBuffer.Contents()).Should(ContainSubstring("Ah, curse your sudden but inevitable betrayal!")) - - Eventually(session).Should(Exit()) - - Expect(outWriterBuffer.Contents()).Should(Equal(session.Out.Contents())) - Expect(errWriterBuffer.Contents()).Should(Equal(session.Err.Contents())) - }) - - Context("when discarding the output of the command", func() { - BeforeEach(func() { - outWriter = ioutil.Discard - errWriter = ioutil.Discard - }) - - It("executes succesfuly", func() { - Eventually(session).Should(Exit()) - }) - }) - }) - - Describe("when the command fails to start", func() { - It("should return an error", func() { - _, err := Start(exec.Command("agklsjdfas"), nil, nil) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/ghttp/handlers.go b/vendor/github.com/onsi/gomega/ghttp/handlers.go deleted file mode 100644 index 894eae6d47..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/handlers.go +++ /dev/null @@ -1,322 +0,0 @@ -package ghttp - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "net/url" - "reflect" - "strings" - - "github.com/golang/protobuf/proto" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/types" -) - -//CombineHandler takes variadic list of handlers and produces one handler -//that calls each handler in order. -func CombineHandlers(handlers ...http.HandlerFunc) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - for _, handler := range handlers { - handler(w, req) - } - } -} - -//VerifyRequest returns a handler that verifies that a request uses the specified method to connect to the specified path -//You may also pass in an optional rawQuery string which is tested against the request's `req.URL.RawQuery` -// -//For path, you may pass in a string, in which case strict equality will be applied -//Alternatively you can pass in a matcher (ContainSubstring("/foo") and MatchRegexp("/foo/[a-f0-9]+") for example) -func VerifyRequest(method string, path interface{}, rawQuery ...string) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - Expect(req.Method).Should(Equal(method), "Method mismatch") - switch p := path.(type) { - case types.GomegaMatcher: - Expect(req.URL.Path).Should(p, "Path mismatch") - default: - Expect(req.URL.Path).Should(Equal(path), "Path mismatch") - } - if len(rawQuery) > 0 { - values, err := url.ParseQuery(rawQuery[0]) - Expect(err).ShouldNot(HaveOccurred(), "Expected RawQuery is malformed") - - Expect(req.URL.Query()).Should(Equal(values), "RawQuery mismatch") - } - } -} - -//VerifyContentType returns a handler that verifies that a request has a Content-Type header set to the -//specified value -func VerifyContentType(contentType string) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - Expect(req.Header.Get("Content-Type")).Should(Equal(contentType)) - } -} - -//VerifyMimeType returns a handler that verifies that a request has a specified mime type set -//in Content-Type header -func VerifyMimeType(mimeType string) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - Expect(strings.Split(req.Header.Get("Content-Type"), ";")[0]).Should(Equal(mimeType)) - } -} - -//VerifyBasicAuth returns a handler that verifies the request contains a BasicAuth Authorization header -//matching the passed in username and password -func VerifyBasicAuth(username string, password string) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - auth := req.Header.Get("Authorization") - Expect(auth).ShouldNot(Equal(""), "Authorization header must be specified") - - decoded, err := base64.StdEncoding.DecodeString(auth[6:]) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(string(decoded)).Should(Equal(fmt.Sprintf("%s:%s", username, password)), "Authorization mismatch") - } -} - -//VerifyHeader returns a handler that verifies the request contains the passed in headers. -//The passed in header keys are first canonicalized via http.CanonicalHeaderKey. -// -//The request must contain *all* the passed in headers, but it is allowed to have additional headers -//beyond the passed in set. -func VerifyHeader(header http.Header) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - for key, values := range header { - key = http.CanonicalHeaderKey(key) - Expect(req.Header[key]).Should(Equal(values), "Header mismatch for key: %s", key) - } - } -} - -//VerifyHeaderKV returns a handler that verifies the request contains a header matching the passed in key and values -//(recall that a `http.Header` is a mapping from string (key) to []string (values)) -//It is a convenience wrapper around `VerifyHeader` that allows you to avoid having to create an `http.Header` object. -func VerifyHeaderKV(key string, values ...string) http.HandlerFunc { - return VerifyHeader(http.Header{key: values}) -} - -//VerifyBody returns a handler that verifies that the body of the request matches the passed in byte array. -//It does this using Equal(). -func VerifyBody(expectedBody []byte) http.HandlerFunc { - return CombineHandlers( - func(w http.ResponseWriter, req *http.Request) { - body, err := ioutil.ReadAll(req.Body) - req.Body.Close() - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(Equal(expectedBody), "Body Mismatch") - }, - ) -} - -//VerifyJSON returns a handler that verifies that the body of the request is a valid JSON representation -//matching the passed in JSON string. It does this using Gomega's MatchJSON method -// -//VerifyJSON also verifies that the request's content type is application/json -func VerifyJSON(expectedJSON string) http.HandlerFunc { - return CombineHandlers( - VerifyMimeType("application/json"), - func(w http.ResponseWriter, req *http.Request) { - body, err := ioutil.ReadAll(req.Body) - req.Body.Close() - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(MatchJSON(expectedJSON), "JSON Mismatch") - }, - ) -} - -//VerifyJSONRepresenting is similar to VerifyJSON. Instead of taking a JSON string, however, it -//takes an arbitrary JSON-encodable object and verifies that the requests's body is a JSON representation -//that matches the object -func VerifyJSONRepresenting(object interface{}) http.HandlerFunc { - data, err := json.Marshal(object) - Expect(err).ShouldNot(HaveOccurred()) - return CombineHandlers( - VerifyContentType("application/json"), - VerifyJSON(string(data)), - ) -} - -//VerifyForm returns a handler that verifies a request contains the specified form values. -// -//The request must contain *all* of the specified values, but it is allowed to have additional -//form values beyond the passed in set. -func VerifyForm(values url.Values) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - err := r.ParseForm() - Expect(err).ShouldNot(HaveOccurred()) - for key, vals := range values { - Expect(r.Form[key]).Should(Equal(vals), "Form mismatch for key: %s", key) - } - } -} - -//VerifyFormKV returns a handler that verifies a request contains a form key with the specified values. -// -//It is a convenience wrapper around `VerifyForm` that lets you avoid having to create a `url.Values` object. -func VerifyFormKV(key string, values ...string) http.HandlerFunc { - return VerifyForm(url.Values{key: values}) -} - -//VerifyProtoRepresenting returns a handler that verifies that the body of the request is a valid protobuf -//representation of the passed message. -// -//VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf -func VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc { - return CombineHandlers( - VerifyContentType("application/x-protobuf"), - func(w http.ResponseWriter, req *http.Request) { - body, err := ioutil.ReadAll(req.Body) - Expect(err).ShouldNot(HaveOccurred()) - req.Body.Close() - - expectedType := reflect.TypeOf(expected) - actualValuePtr := reflect.New(expectedType.Elem()) - - actual, ok := actualValuePtr.Interface().(proto.Message) - Expect(ok).Should(BeTrue(), "Message value is not a proto.Message") - - err = proto.Unmarshal(body, actual) - Expect(err).ShouldNot(HaveOccurred(), "Failed to unmarshal protobuf") - - Expect(actual).Should(Equal(expected), "ProtoBuf Mismatch") - }, - ) -} - -func copyHeader(src http.Header, dst http.Header) { - for key, value := range src { - dst[key] = value - } -} - -/* -RespondWith returns a handler that responds to a request with the specified status code and body - -Body may be a string or []byte - -Also, RespondWith can be given an optional http.Header. The headers defined therein will be added to the response headers. -*/ -func RespondWith(statusCode int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - if len(optionalHeader) == 1 { - copyHeader(optionalHeader[0], w.Header()) - } - w.WriteHeader(statusCode) - switch x := body.(type) { - case string: - w.Write([]byte(x)) - case []byte: - w.Write(x) - default: - Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.") - } - } -} - -/* -RespondWithPtr returns a handler that responds to a request with the specified status code and body - -Unlike RespondWith, you pass RepondWithPtr a pointer to the status code and body allowing different tests -to share the same setup but specify different status codes and bodies. - -Also, RespondWithPtr can be given an optional http.Header. The headers defined therein will be added to the response headers. -Since the http.Header can be mutated after the fact you don't need to pass in a pointer. -*/ -func RespondWithPtr(statusCode *int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - if len(optionalHeader) == 1 { - copyHeader(optionalHeader[0], w.Header()) - } - w.WriteHeader(*statusCode) - if body != nil { - switch x := (body).(type) { - case *string: - w.Write([]byte(*x)) - case *[]byte: - w.Write(*x) - default: - Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.") - } - } - } -} - -/* -RespondWithJSONEncoded returns a handler that responds to a request with the specified status code and a body -containing the JSON-encoding of the passed in object - -Also, RespondWithJSONEncoded can be given an optional http.Header. The headers defined therein will be added to the response headers. -*/ -func RespondWithJSONEncoded(statusCode int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { - data, err := json.Marshal(object) - Expect(err).ShouldNot(HaveOccurred()) - - var headers http.Header - if len(optionalHeader) == 1 { - headers = optionalHeader[0] - } else { - headers = make(http.Header) - } - if _, found := headers["Content-Type"]; !found { - headers["Content-Type"] = []string{"application/json"} - } - return RespondWith(statusCode, string(data), headers) -} - -/* -RespondWithJSONEncodedPtr behaves like RespondWithJSONEncoded but takes a pointer -to a status code and object. - -This allows different tests to share the same setup but specify different status codes and JSON-encoded -objects. - -Also, RespondWithJSONEncodedPtr can be given an optional http.Header. The headers defined therein will be added to the response headers. -Since the http.Header can be mutated after the fact you don't need to pass in a pointer. -*/ -func RespondWithJSONEncodedPtr(statusCode *int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - data, err := json.Marshal(object) - Expect(err).ShouldNot(HaveOccurred()) - var headers http.Header - if len(optionalHeader) == 1 { - headers = optionalHeader[0] - } else { - headers = make(http.Header) - } - if _, found := headers["Content-Type"]; !found { - headers["Content-Type"] = []string{"application/json"} - } - copyHeader(headers, w.Header()) - w.WriteHeader(*statusCode) - w.Write(data) - } -} - -//RespondWithProto returns a handler that responds to a request with the specified status code and a body -//containing the protobuf serialization of the provided message. -// -//Also, RespondWithProto can be given an optional http.Header. The headers defined therein will be added to the response headers. -func RespondWithProto(statusCode int, message proto.Message, optionalHeader ...http.Header) http.HandlerFunc { - return func(w http.ResponseWriter, req *http.Request) { - data, err := proto.Marshal(message) - Expect(err).ShouldNot(HaveOccurred()) - - var headers http.Header - if len(optionalHeader) == 1 { - headers = optionalHeader[0] - } else { - headers = make(http.Header) - } - if _, found := headers["Content-Type"]; !found { - headers["Content-Type"] = []string{"application/x-protobuf"} - } - copyHeader(headers, w.Header()) - - w.WriteHeader(statusCode) - w.Write(data) - } -} diff --git a/vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go b/vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go deleted file mode 100644 index b2972bc9fb..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go +++ /dev/null @@ -1,3 +0,0 @@ -package protobuf - -//go:generate protoc --go_out=. simple_message.proto diff --git a/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go b/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go deleted file mode 100644 index c55a48448f..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by protoc-gen-go. -// source: simple_message.proto -// DO NOT EDIT! - -/* -Package protobuf is a generated protocol buffer package. - -It is generated from these files: - simple_message.proto - -It has these top-level messages: - SimpleMessage -*/ -package protobuf - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type SimpleMessage struct { - Description *string `protobuf:"bytes,1,req,name=description" json:"description,omitempty"` - Id *int32 `protobuf:"varint,2,req,name=id" json:"id,omitempty"` - Metadata *string `protobuf:"bytes,3,opt,name=metadata" json:"metadata,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *SimpleMessage) Reset() { *m = SimpleMessage{} } -func (m *SimpleMessage) String() string { return proto.CompactTextString(m) } -func (*SimpleMessage) ProtoMessage() {} - -func (m *SimpleMessage) GetDescription() string { - if m != nil && m.Description != nil { - return *m.Description - } - return "" -} - -func (m *SimpleMessage) GetId() int32 { - if m != nil && m.Id != nil { - return *m.Id - } - return 0 -} - -func (m *SimpleMessage) GetMetadata() string { - if m != nil && m.Metadata != nil { - return *m.Metadata - } - return "" -} diff --git a/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto b/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto deleted file mode 100644 index 35b7145c24..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto2"; - -package protobuf; - -message SimpleMessage { - required string description = 1; - required int32 id = 2; - optional string metadata = 3; -} diff --git a/vendor/github.com/onsi/gomega/ghttp/test_server.go b/vendor/github.com/onsi/gomega/ghttp/test_server.go deleted file mode 100644 index 77535f3097..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/test_server.go +++ /dev/null @@ -1,422 +0,0 @@ -/* -Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports -registering multiple handlers. Incoming requests are not routed between the different handlers -- rather it is merely the order of the handlers that matters. The first request is handled by the first -registered handler, the second request by the second handler, etc. - -The intent here is to have each handler *verify* that the incoming request is valid. To accomplish, ghttp -also provides a collection of bite-size handlers that each perform one aspect of request verification. These can -be composed together and registered with a ghttp server. The result is an expressive language for describing -the requests generated by the client under test. - -Here's a simple example, note that the server handler is only defined in one BeforeEach and then modified, as required, by the nested BeforeEaches. -A more comprehensive example is available at https://onsi.github.io/gomega/#_testing_http_clients - - var _ = Describe("A Sprockets Client", func() { - var server *ghttp.Server - var client *SprocketClient - BeforeEach(func() { - server = ghttp.NewServer() - client = NewSprocketClient(server.URL(), "skywalker", "tk427") - }) - - AfterEach(func() { - server.Close() - }) - - Describe("fetching sprockets", func() { - var statusCode int - var sprockets []Sprocket - BeforeEach(func() { - statusCode = http.StatusOK - sprockets = []Sprocket{} - server.AppendHandlers(ghttp.CombineHandlers( - ghttp.VerifyRequest("GET", "/sprockets"), - ghttp.VerifyBasicAuth("skywalker", "tk427"), - ghttp.RespondWithJSONEncodedPtr(&statusCode, &sprockets), - )) - }) - - Context("when requesting all sprockets", func() { - Context("when the response is succesful", func() { - BeforeEach(func() { - sprockets = []Sprocket{ - NewSprocket("Alfalfa"), - NewSprocket("Banana"), - } - }) - - It("should return the returned sprockets", func() { - Expect(client.Sprockets()).Should(Equal(sprockets)) - }) - }) - - Context("when the response is missing", func() { - BeforeEach(func() { - statusCode = http.StatusNotFound - }) - - It("should return an empty list of sprockets", func() { - Expect(client.Sprockets()).Should(BeEmpty()) - }) - }) - - Context("when the response fails to authenticate", func() { - BeforeEach(func() { - statusCode = http.StatusUnauthorized - }) - - It("should return an AuthenticationError error", func() { - sprockets, err := client.Sprockets() - Expect(sprockets).Should(BeEmpty()) - Expect(err).Should(MatchError(AuthenticationError)) - }) - }) - - Context("when the response is a server failure", func() { - BeforeEach(func() { - statusCode = http.StatusInternalServerError - }) - - It("should return an InternalError error", func() { - sprockets, err := client.Sprockets() - Expect(sprockets).Should(BeEmpty()) - Expect(err).Should(MatchError(InternalError)) - }) - }) - }) - - Context("when requesting some sprockets", func() { - BeforeEach(func() { - sprockets = []Sprocket{ - NewSprocket("Alfalfa"), - NewSprocket("Banana"), - } - - server.WrapHandler(0, ghttp.VerifyRequest("GET", "/sprockets", "filter=FOOD")) - }) - - It("should make the request with a filter", func() { - Expect(client.Sprockets("food")).Should(Equal(sprockets)) - }) - }) - }) - }) -*/ -package ghttp - -import ( - "fmt" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "net/http/httputil" - "reflect" - "regexp" - "strings" - "sync" - - . "github.com/onsi/gomega" -) - -func new() *Server { - return &Server{ - AllowUnhandledRequests: false, - UnhandledRequestStatusCode: http.StatusInternalServerError, - rwMutex: &sync.RWMutex{}, - } -} - -type routedHandler struct { - method string - pathRegexp *regexp.Regexp - path string - handler http.HandlerFunc -} - -// NewServer returns a new `*ghttp.Server` that wraps an `httptest` server. The server is started automatically. -func NewServer() *Server { - s := new() - s.HTTPTestServer = httptest.NewServer(s) - return s -} - -// NewUnstartedServer return a new, unstarted, `*ghttp.Server`. Useful for specifying a custom listener on `server.HTTPTestServer`. -func NewUnstartedServer() *Server { - s := new() - s.HTTPTestServer = httptest.NewUnstartedServer(s) - return s -} - -// NewTLSServer returns a new `*ghttp.Server` that wraps an `httptest` TLS server. The server is started automatically. -func NewTLSServer() *Server { - s := new() - s.HTTPTestServer = httptest.NewTLSServer(s) - return s -} - -type Server struct { - //The underlying httptest server - HTTPTestServer *httptest.Server - - //Defaults to false. If set to true, the Server will allow more requests than there are registered handlers. - //Direct use of this property is deprecated and is likely to be removed, use GetAllowUnhandledRequests and SetAllowUnhandledRequests instead. - AllowUnhandledRequests bool - - //The status code returned when receiving an unhandled request. - //Defaults to http.StatusInternalServerError. - //Only applies if AllowUnhandledRequests is true - //Direct use of this property is deprecated and is likely to be removed, use GetUnhandledRequestStatusCode and SetUnhandledRequestStatusCode instead. - UnhandledRequestStatusCode int - - //If provided, ghttp will log about each request received to the provided io.Writer - //Defaults to nil - //If you're using Ginkgo, set this to GinkgoWriter to get improved output during failures - Writer io.Writer - - receivedRequests []*http.Request - requestHandlers []http.HandlerFunc - routedHandlers []routedHandler - - rwMutex *sync.RWMutex - calls int -} - -//Start() starts an unstarted ghttp server. It is a catastrophic error to call Start more than once (thanks, httptest). -func (s *Server) Start() { - s.HTTPTestServer.Start() -} - -//URL() returns a url that will hit the server -func (s *Server) URL() string { - s.rwMutex.RLock() - defer s.rwMutex.RUnlock() - return s.HTTPTestServer.URL -} - -//Addr() returns the address on which the server is listening. -func (s *Server) Addr() string { - s.rwMutex.RLock() - defer s.rwMutex.RUnlock() - return s.HTTPTestServer.Listener.Addr().String() -} - -//Close() should be called at the end of each test. It spins down and cleans up the test server. -func (s *Server) Close() { - s.rwMutex.Lock() - server := s.HTTPTestServer - s.HTTPTestServer = nil - s.rwMutex.Unlock() - - if server != nil { - server.Close() - } -} - -//ServeHTTP() makes Server an http.Handler -//When the server receives a request it handles the request in the following order: -// -//1. If the request matches a handler registered with RouteToHandler, that handler is called. -//2. Otherwise, if there are handlers registered via AppendHandlers, those handlers are called in order. -//3. If all registered handlers have been called then: -// a) If AllowUnhandledRequests is set to true, the request will be handled with response code of UnhandledRequestStatusCode -// b) If AllowUnhandledRequests is false, the request will not be handled and the current test will be marked as failed. -func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { - s.rwMutex.Lock() - defer func() { - e := recover() - if e != nil { - w.WriteHeader(http.StatusInternalServerError) - } - - //If the handler panics GHTTP will silently succeed. This is bad™. - //To catch this case we need to fail the test if the handler has panicked. - //However, if the handler is panicking because Ginkgo's causing it to panic (i.e. an assertion failed) - //then we shouldn't double-report the error as this will confuse people. - - //So: step 1, if this is a Ginkgo panic - do nothing, Ginkgo's aware of the failure - eAsString, ok := e.(string) - if ok && strings.Contains(eAsString, "defer GinkgoRecover()") { - return - } - - //If we're here, we have to do step 2: assert that the error is nil. This assertion will - //allow us to fail the test suite (note: we can't call Fail since Gomega is not allowed to import Ginkgo). - //Since a failed assertion throws a panic, and we are likely in a goroutine, we need to defer within our defer! - defer func() { - recover() - }() - Expect(e).Should(BeNil(), "Handler Panicked") - }() - - if s.Writer != nil { - s.Writer.Write([]byte(fmt.Sprintf("GHTTP Received Request: %s - %s\n", req.Method, req.URL))) - } - - s.receivedRequests = append(s.receivedRequests, req) - if routedHandler, ok := s.handlerForRoute(req.Method, req.URL.Path); ok { - s.rwMutex.Unlock() - routedHandler(w, req) - } else if s.calls < len(s.requestHandlers) { - h := s.requestHandlers[s.calls] - s.calls++ - s.rwMutex.Unlock() - h(w, req) - } else { - s.rwMutex.Unlock() - if s.GetAllowUnhandledRequests() { - ioutil.ReadAll(req.Body) - req.Body.Close() - w.WriteHeader(s.GetUnhandledRequestStatusCode()) - } else { - formatted, err := httputil.DumpRequest(req, true) - Expect(err).NotTo(HaveOccurred(), "Encountered error while dumping HTTP request") - Expect(string(formatted)).Should(BeNil(), "Received Unhandled Request") - } - } -} - -//ReceivedRequests is an array containing all requests received by the server (both handled and unhandled requests) -func (s *Server) ReceivedRequests() []*http.Request { - s.rwMutex.RLock() - defer s.rwMutex.RUnlock() - - return s.receivedRequests -} - -//RouteToHandler can be used to register handlers that will always handle requests that match -//the passed in method and path. -// -//The path may be either a string object or a *regexp.Regexp. -func (s *Server) RouteToHandler(method string, path interface{}, handler http.HandlerFunc) { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - rh := routedHandler{ - method: method, - handler: handler, - } - - switch p := path.(type) { - case *regexp.Regexp: - rh.pathRegexp = p - case string: - rh.path = p - default: - panic("path must be a string or a regular expression") - } - - for i, existingRH := range s.routedHandlers { - if existingRH.method == method && - reflect.DeepEqual(existingRH.pathRegexp, rh.pathRegexp) && - existingRH.path == rh.path { - s.routedHandlers[i] = rh - return - } - } - s.routedHandlers = append(s.routedHandlers, rh) -} - -func (s *Server) handlerForRoute(method string, path string) (http.HandlerFunc, bool) { - for _, rh := range s.routedHandlers { - if rh.method == method { - if rh.pathRegexp != nil { - if rh.pathRegexp.Match([]byte(path)) { - return rh.handler, true - } - } else if rh.path == path { - return rh.handler, true - } - } - } - - return nil, false -} - -//AppendHandlers will appends http.HandlerFuncs to the server's list of registered handlers. The first incoming request is handled by the first handler, the second by the second, etc... -func (s *Server) AppendHandlers(handlers ...http.HandlerFunc) { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - s.requestHandlers = append(s.requestHandlers, handlers...) -} - -//SetHandler overrides the registered handler at the passed in index with the passed in handler -//This is useful, for example, when a server has been set up in a shared context, but must be tweaked -//for a particular test. -func (s *Server) SetHandler(index int, handler http.HandlerFunc) { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - s.requestHandlers[index] = handler -} - -//GetHandler returns the handler registered at the passed in index. -func (s *Server) GetHandler(index int) http.HandlerFunc { - s.rwMutex.RLock() - defer s.rwMutex.RUnlock() - - return s.requestHandlers[index] -} - -func (s *Server) Reset() { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - s.HTTPTestServer.CloseClientConnections() - s.calls = 0 - s.receivedRequests = nil - s.requestHandlers = nil - s.routedHandlers = nil -} - -//WrapHandler combines the passed in handler with the handler registered at the passed in index. -//This is useful, for example, when a server has been set up in a shared context but must be tweaked -//for a particular test. -// -//If the currently registered handler is A, and the new passed in handler is B then -//WrapHandler will generate a new handler that first calls A, then calls B, and assign it to index -func (s *Server) WrapHandler(index int, handler http.HandlerFunc) { - existingHandler := s.GetHandler(index) - s.SetHandler(index, CombineHandlers(existingHandler, handler)) -} - -func (s *Server) CloseClientConnections() { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - s.HTTPTestServer.CloseClientConnections() -} - -//SetAllowUnhandledRequests enables the server to accept unhandled requests. -func (s *Server) SetAllowUnhandledRequests(allowUnhandledRequests bool) { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - s.AllowUnhandledRequests = allowUnhandledRequests -} - -//GetAllowUnhandledRequests returns true if the server accepts unhandled requests. -func (s *Server) GetAllowUnhandledRequests() bool { - s.rwMutex.RLock() - defer s.rwMutex.RUnlock() - - return s.AllowUnhandledRequests -} - -//SetUnhandledRequestStatusCode status code to be returned when the server receives unhandled requests -func (s *Server) SetUnhandledRequestStatusCode(statusCode int) { - s.rwMutex.Lock() - defer s.rwMutex.Unlock() - - s.UnhandledRequestStatusCode = statusCode -} - -//GetUnhandledRequestStatusCode returns the current status code being returned for unhandled requests -func (s *Server) GetUnhandledRequestStatusCode() int { - s.rwMutex.RLock() - defer s.rwMutex.RUnlock() - - return s.UnhandledRequestStatusCode -} diff --git a/vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go b/vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go deleted file mode 100644 index 7c12360827..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package ghttp_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestGHTTP(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "GHTTP Suite") -} diff --git a/vendor/github.com/onsi/gomega/ghttp/test_server_test.go b/vendor/github.com/onsi/gomega/ghttp/test_server_test.go deleted file mode 100644 index be1c58e820..0000000000 --- a/vendor/github.com/onsi/gomega/ghttp/test_server_test.go +++ /dev/null @@ -1,1129 +0,0 @@ -package ghttp_test - -import ( - "bytes" - "io" - "io/ioutil" - "net/http" - "net/url" - "regexp" - - "github.com/golang/protobuf/proto" - "github.com/onsi/gomega/gbytes" - "github.com/onsi/gomega/ghttp/protobuf" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/ghttp" -) - -var _ = Describe("TestServer", func() { - var ( - resp *http.Response - err error - s *Server - ) - - BeforeEach(func() { - s = NewServer() - }) - - AfterEach(func() { - s.Close() - }) - - Describe("Resetting the server", func() { - BeforeEach(func() { - s.RouteToHandler("GET", "/", func(w http.ResponseWriter, req *http.Request) {}) - s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {}) - http.Get(s.URL() + "/") - - Expect(s.ReceivedRequests()).Should(HaveLen(1)) - }) - - It("clears all handlers and call counts", func() { - s.Reset() - Expect(s.ReceivedRequests()).Should(HaveLen(0)) - Expect(func() { s.GetHandler(0) }).Should(Panic()) - }) - }) - - Describe("closing client connections", func() { - It("closes", func() { - s.RouteToHandler("GET", "/", - func(w http.ResponseWriter, req *http.Request) { - io.WriteString(w, req.RemoteAddr) - }, - ) - client := http.Client{Transport: &http.Transport{DisableKeepAlives: true}} - resp, err := client.Get(s.URL()) - Expect(err).ShouldNot(HaveOccurred()) - Expect(resp.StatusCode).Should(Equal(200)) - - body, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - Expect(err).ShouldNot(HaveOccurred()) - - s.CloseClientConnections() - - resp, err = client.Get(s.URL()) - Expect(err).ShouldNot(HaveOccurred()) - Expect(resp.StatusCode).Should(Equal(200)) - - body2, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - Expect(err).ShouldNot(HaveOccurred()) - - Expect(body2).ShouldNot(Equal(body)) - }) - }) - - Describe("closing server mulitple times", func() { - It("should not fail", func() { - s.Close() - Expect(s.Close).ShouldNot(Panic()) - }) - }) - - Describe("allowing unhandled requests", func() { - It("is not permitted by default", func() { - Expect(s.GetAllowUnhandledRequests()).To(BeFalse()) - }) - - Context("when true", func() { - BeforeEach(func() { - s.SetAllowUnhandledRequests(true) - s.SetUnhandledRequestStatusCode(http.StatusForbidden) - resp, err = http.Get(s.URL() + "/foo") - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should allow unhandled requests and respond with the passed in status code", func() { - Expect(err).ShouldNot(HaveOccurred()) - Expect(resp.StatusCode).Should(Equal(http.StatusForbidden)) - - data, err := ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(data).Should(BeEmpty()) - }) - - It("should record the requests", func() { - Expect(s.ReceivedRequests()).Should(HaveLen(1)) - Expect(s.ReceivedRequests()[0].URL.Path).Should(Equal("/foo")) - }) - }) - - Context("when false", func() { - It("should fail when attempting a request", func() { - failures := InterceptGomegaFailures(func() { - http.Get(s.URL() + "/foo") - }) - - Expect(failures[0]).Should(ContainSubstring("Received Unhandled Request")) - }) - }) - }) - - Describe("Managing Handlers", func() { - var called []string - BeforeEach(func() { - called = []string{} - s.RouteToHandler("GET", "/routed", func(w http.ResponseWriter, req *http.Request) { - called = append(called, "r1") - }) - s.RouteToHandler("POST", regexp.MustCompile(`/routed\d`), func(w http.ResponseWriter, req *http.Request) { - called = append(called, "r2") - }) - s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) { - called = append(called, "A") - }, func(w http.ResponseWriter, req *http.Request) { - called = append(called, "B") - }) - }) - - It("should prefer routed handlers if there is a match", func() { - http.Get(s.URL() + "/routed") - http.Post(s.URL()+"/routed7", "application/json", nil) - http.Get(s.URL() + "/foo") - http.Get(s.URL() + "/routed") - http.Post(s.URL()+"/routed9", "application/json", nil) - http.Get(s.URL() + "/bar") - - failures := InterceptGomegaFailures(func() { - http.Get(s.URL() + "/foo") - http.Get(s.URL() + "/routed/not/a/match") - http.Get(s.URL() + "/routed7") - http.Post(s.URL()+"/routed", "application/json", nil) - }) - - Expect(failures[0]).Should(ContainSubstring("Received Unhandled Request")) - Expect(failures).Should(HaveLen(4)) - - http.Post(s.URL()+"/routed3", "application/json", nil) - - Expect(called).Should(Equal([]string{"r1", "r2", "A", "r1", "r2", "B", "r2"})) - }) - - It("should override routed handlers when reregistered", func() { - s.RouteToHandler("GET", "/routed", func(w http.ResponseWriter, req *http.Request) { - called = append(called, "r3") - }) - s.RouteToHandler("POST", regexp.MustCompile(`/routed\d`), func(w http.ResponseWriter, req *http.Request) { - called = append(called, "r4") - }) - - http.Get(s.URL() + "/routed") - http.Post(s.URL()+"/routed7", "application/json", nil) - - Expect(called).Should(Equal([]string{"r3", "r4"})) - }) - - It("should call the appended handlers, in order, as requests come in", func() { - http.Get(s.URL() + "/foo") - Expect(called).Should(Equal([]string{"A"})) - - http.Get(s.URL() + "/foo") - Expect(called).Should(Equal([]string{"A", "B"})) - - failures := InterceptGomegaFailures(func() { - http.Get(s.URL() + "/foo") - }) - - Expect(failures[0]).Should(ContainSubstring("Received Unhandled Request")) - }) - - Describe("Overwriting an existing handler", func() { - BeforeEach(func() { - s.SetHandler(0, func(w http.ResponseWriter, req *http.Request) { - called = append(called, "C") - }) - }) - - It("should override the specified handler", func() { - http.Get(s.URL() + "/foo") - http.Get(s.URL() + "/foo") - Expect(called).Should(Equal([]string{"C", "B"})) - }) - }) - - Describe("Getting an existing handler", func() { - It("should return the handler func", func() { - s.GetHandler(1)(nil, nil) - Expect(called).Should(Equal([]string{"B"})) - }) - }) - - Describe("Wrapping an existing handler", func() { - BeforeEach(func() { - s.WrapHandler(0, func(w http.ResponseWriter, req *http.Request) { - called = append(called, "C") - }) - }) - - It("should wrap the existing handler in a new handler", func() { - http.Get(s.URL() + "/foo") - http.Get(s.URL() + "/foo") - Expect(called).Should(Equal([]string{"A", "C", "B"})) - }) - }) - }) - - Describe("When a handler fails", func() { - BeforeEach(func() { - s.SetUnhandledRequestStatusCode(http.StatusForbidden) //just to be clear that 500s aren't coming from unhandled requests - }) - - Context("because the handler has panicked", func() { - BeforeEach(func() { - s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) { - panic("bam") - }) - }) - - It("should respond with a 500 and make a failing assertion", func() { - var resp *http.Response - var err error - - failures := InterceptGomegaFailures(func() { - resp, err = http.Get(s.URL()) - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(resp.StatusCode).Should(Equal(http.StatusInternalServerError)) - Expect(failures).Should(ConsistOf(ContainSubstring("Handler Panicked"))) - }) - }) - - Context("because an assertion has failed", func() { - BeforeEach(func() { - s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) { - // Expect(true).Should(BeFalse()) <-- would be nice to do it this way, but the test just can't be written this way - - By("We're cheating a bit here -- we're throwing a GINKGO_PANIC which simulates a failed assertion") - panic(GINKGO_PANIC) - }) - }) - - It("should respond with a 500 and *not* make a failing assertion, instead relying on Ginkgo to have already been notified of the error", func() { - resp, err := http.Get(s.URL()) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(resp.StatusCode).Should(Equal(http.StatusInternalServerError)) - }) - }) - }) - - Describe("Logging to the Writer", func() { - var buf *gbytes.Buffer - BeforeEach(func() { - buf = gbytes.NewBuffer() - s.Writer = buf - s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {}) - s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {}) - }) - - It("should write to the buffer when a request comes in", func() { - http.Get(s.URL() + "/foo") - Expect(buf).Should(gbytes.Say("GHTTP Received Request: GET - /foo\n")) - - http.Post(s.URL()+"/bar", "", nil) - Expect(buf).Should(gbytes.Say("GHTTP Received Request: POST - /bar\n")) - }) - }) - - Describe("Request Handlers", func() { - Describe("VerifyRequest", func() { - BeforeEach(func() { - s.AppendHandlers(VerifyRequest("GET", "/foo")) - }) - - It("should verify the method, path", func() { - resp, err = http.Get(s.URL() + "/foo?baz=bar") - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the method, path", func() { - failures := InterceptGomegaFailures(func() { - http.Get(s.URL() + "/foo2") - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("should verify the method, path", func() { - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/foo", "application/json", nil) - }) - Expect(failures).Should(HaveLen(1)) - }) - - Context("when passed a rawQuery", func() { - It("should also be possible to verify the rawQuery", func() { - s.SetHandler(0, VerifyRequest("GET", "/foo", "baz=bar")) - resp, err = http.Get(s.URL() + "/foo?baz=bar") - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should match irregardless of query parameter ordering", func() { - s.SetHandler(0, VerifyRequest("GET", "/foo", "type=get&name=money")) - u, _ := url.Parse(s.URL() + "/foo") - u.RawQuery = url.Values{ - "type": []string{"get"}, - "name": []string{"money"}, - }.Encode() - - resp, err = http.Get(u.String()) - Expect(err).ShouldNot(HaveOccurred()) - }) - }) - - Context("when passed a matcher for path", func() { - It("should apply the matcher", func() { - s.SetHandler(0, VerifyRequest("GET", MatchRegexp(`/foo/[a-f]*/3`))) - resp, err = http.Get(s.URL() + "/foo/abcdefa/3") - Expect(err).ShouldNot(HaveOccurred()) - }) - }) - }) - - Describe("VerifyContentType", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("GET", "/foo"), - VerifyContentType("application/octet-stream"), - )) - }) - - It("should verify the content type", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Set("Content-Type", "application/octet-stream") - - resp, err = http.DefaultClient.Do(req) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the content type", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Set("Content-Type", "application/json") - - failures := InterceptGomegaFailures(func() { - http.DefaultClient.Do(req) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("should verify the content type", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Set("Content-Type", "application/octet-stream; charset=utf-8") - - failures := InterceptGomegaFailures(func() { - http.DefaultClient.Do(req) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("Verify BasicAuth", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("GET", "/foo"), - VerifyBasicAuth("bob", "password"), - )) - }) - - It("should verify basic auth", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.SetBasicAuth("bob", "password") - - resp, err = http.DefaultClient.Do(req) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify basic auth", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.SetBasicAuth("bob", "bassword") - - failures := InterceptGomegaFailures(func() { - http.DefaultClient.Do(req) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("should require basic auth header", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - - failures := InterceptGomegaFailures(func() { - http.DefaultClient.Do(req) - }) - Expect(failures).Should(ContainElement(ContainSubstring("Authorization header must be specified"))) - }) - }) - - Describe("VerifyHeader", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("GET", "/foo"), - VerifyHeader(http.Header{ - "accept": []string{"jpeg", "png"}, - "cache-control": []string{"omicron"}, - "Return-Path": []string{"hobbiton"}, - }), - )) - }) - - It("should verify the headers", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Add("Accept", "jpeg") - req.Header.Add("Accept", "png") - req.Header.Add("Cache-Control", "omicron") - req.Header.Add("return-path", "hobbiton") - - resp, err = http.DefaultClient.Do(req) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the headers", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Add("Schmaccept", "jpeg") - req.Header.Add("Schmaccept", "png") - req.Header.Add("Cache-Control", "omicron") - req.Header.Add("return-path", "hobbiton") - - failures := InterceptGomegaFailures(func() { - http.DefaultClient.Do(req) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("VerifyHeaderKV", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("GET", "/foo"), - VerifyHeaderKV("accept", "jpeg", "png"), - VerifyHeaderKV("cache-control", "omicron"), - VerifyHeaderKV("Return-Path", "hobbiton"), - )) - }) - - It("should verify the headers", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Add("Accept", "jpeg") - req.Header.Add("Accept", "png") - req.Header.Add("Cache-Control", "omicron") - req.Header.Add("return-path", "hobbiton") - - resp, err = http.DefaultClient.Do(req) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the headers", func() { - req, err := http.NewRequest("GET", s.URL()+"/foo", nil) - Expect(err).ShouldNot(HaveOccurred()) - req.Header.Add("Accept", "jpeg") - req.Header.Add("Cache-Control", "omicron") - req.Header.Add("return-path", "hobbiton") - - failures := InterceptGomegaFailures(func() { - http.DefaultClient.Do(req) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("VerifyBody", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - VerifyBody([]byte("some body")), - )) - }) - - It("should verify the body", func() { - resp, err = http.Post(s.URL()+"/foo", "", bytes.NewReader([]byte("some body"))) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the body", func() { - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/foo", "", bytes.NewReader([]byte("wrong body"))) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("VerifyMimeType", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyMimeType("application/json"), - )) - }) - - It("should verify the mime type in content-type header", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json; charset=utf-8", bytes.NewReader([]byte(`{}`))) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the mime type in content-type header", func() { - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/foo", "text/plain", bytes.NewReader([]byte(`{}`))) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("VerifyJSON", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - VerifyJSON(`{"a":3, "b":2}`), - )) - }) - - It("should verify the json body and the content type", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`{"b":2, "a":3}`))) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the json body and the content type", func() { - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`{"b":2, "a":4}`))) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("should verify the json body and the content type", func() { - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/foo", "application/not-json", bytes.NewReader([]byte(`{"b":2, "a":3}`))) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("should verify the json body and the content type", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json; charset=utf-8", bytes.NewReader([]byte(`{"b":2, "a":3}`))) - Expect(err).ShouldNot(HaveOccurred()) - }) - }) - - Describe("VerifyJSONRepresenting", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - VerifyJSONRepresenting([]int{1, 3, 5}), - )) - }) - - It("should verify the json body and the content type", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`[1,3,5]`))) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the json body and the content type", func() { - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`[1,3]`))) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("VerifyForm", func() { - var formValues url.Values - - BeforeEach(func() { - formValues = make(url.Values) - formValues.Add("users", "user1") - formValues.Add("users", "user2") - formValues.Add("group", "users") - }) - - Context("when encoded in the URL", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("GET", "/foo"), - VerifyForm(url.Values{ - "users": []string{"user1", "user2"}, - "group": []string{"users"}, - }), - )) - }) - - It("should verify form values", func() { - resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode()) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should ignore extra values", func() { - formValues.Add("extra", "value") - resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode()) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("fail on missing values", func() { - formValues.Del("group") - failures := InterceptGomegaFailures(func() { - resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode()) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("fail on incorrect values", func() { - formValues.Set("group", "wheel") - failures := InterceptGomegaFailures(func() { - resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode()) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Context("when present in the body", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - VerifyForm(url.Values{ - "users": []string{"user1", "user2"}, - "group": []string{"users"}, - }), - )) - }) - - It("should verify form values", func() { - resp, err = http.PostForm(s.URL()+"/foo", formValues) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should ignore extra values", func() { - formValues.Add("extra", "value") - resp, err = http.PostForm(s.URL()+"/foo", formValues) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("fail on missing values", func() { - formValues.Del("group") - failures := InterceptGomegaFailures(func() { - resp, err = http.PostForm(s.URL()+"/foo", formValues) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("fail on incorrect values", func() { - formValues.Set("group", "wheel") - failures := InterceptGomegaFailures(func() { - resp, err = http.PostForm(s.URL()+"/foo", formValues) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - }) - - Describe("VerifyFormKV", func() { - Context("when encoded in the URL", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("GET", "/foo"), - VerifyFormKV("users", "user1", "user2"), - )) - }) - - It("verifies the form value", func() { - resp, err = http.Get(s.URL() + "/foo?users=user1&users=user2") - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("verifies the form value", func() { - failures := InterceptGomegaFailures(func() { - resp, err = http.Get(s.URL() + "/foo?users=user1") - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Context("when present in the body", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - VerifyFormKV("users", "user1", "user2"), - )) - }) - - It("verifies the form value", func() { - resp, err = http.PostForm(s.URL()+"/foo", url.Values{"users": []string{"user1", "user2"}}) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("verifies the form value", func() { - failures := InterceptGomegaFailures(func() { - resp, err = http.PostForm(s.URL()+"/foo", url.Values{"users": []string{"user1"}}) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - }) - - Describe("VerifyProtoRepresenting", func() { - var message *protobuf.SimpleMessage - - BeforeEach(func() { - message = new(protobuf.SimpleMessage) - message.Description = proto.String("A description") - message.Id = proto.Int32(0) - - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/proto"), - VerifyProtoRepresenting(message), - )) - }) - - It("verifies the proto body and the content type", func() { - serialized, err := proto.Marshal(message) - Expect(err).ShouldNot(HaveOccurred()) - - resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", bytes.NewReader(serialized)) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should verify the proto body and the content type", func() { - serialized, err := proto.Marshal(&protobuf.SimpleMessage{ - Description: proto.String("A description"), - Id: proto.Int32(0), - Metadata: proto.String("some metadata"), - }) - Expect(err).ShouldNot(HaveOccurred()) - - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/proto", "application/x-protobuf", bytes.NewReader(serialized)) - }) - Expect(failures).Should(HaveLen(1)) - }) - - It("should verify the proto body and the content type", func() { - serialized, err := proto.Marshal(message) - Expect(err).ShouldNot(HaveOccurred()) - - failures := InterceptGomegaFailures(func() { - http.Post(s.URL()+"/proto", "application/not-x-protobuf", bytes.NewReader(serialized)) - }) - Expect(failures).Should(HaveLen(1)) - }) - }) - - Describe("RespondWith", func() { - Context("without headers", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWith(http.StatusCreated, "sweet"), - ), CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWith(http.StatusOK, []byte("sour")), - )) - }) - - It("should return the response", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - - body, err := ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(Equal([]byte("sweet"))) - - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - - body, err = ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(Equal([]byte("sour"))) - }) - }) - - Context("with headers", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWith(http.StatusCreated, "sweet", http.Header{"X-Custom-Header": []string{"my header"}}), - )) - }) - - It("should return the headers too", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - Expect(ioutil.ReadAll(resp.Body)).Should(Equal([]byte("sweet"))) - Expect(resp.Header.Get("X-Custom-Header")).Should(Equal("my header")) - }) - }) - }) - - Describe("RespondWithPtr", func() { - var code int - var byteBody []byte - var stringBody string - BeforeEach(func() { - code = http.StatusOK - byteBody = []byte("sweet") - stringBody = "sour" - - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithPtr(&code, &byteBody), - ), CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithPtr(&code, &stringBody), - )) - }) - - It("should return the response", func() { - code = http.StatusCreated - byteBody = []byte("tasty") - stringBody = "treat" - - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - - body, err := ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(Equal([]byte("tasty"))) - - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - - body, err = ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(Equal([]byte("treat"))) - }) - - Context("when passed a nil body", func() { - BeforeEach(func() { - s.SetHandler(0, CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithPtr(&code, nil), - )) - }) - - It("should return an empty body and not explode", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - body, err := ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(BeEmpty()) - - Expect(s.ReceivedRequests()).Should(HaveLen(1)) - }) - }) - }) - - Describe("RespondWithJSON", func() { - Context("when no optional headers are set", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithJSONEncoded(http.StatusCreated, []int{1, 2, 3}), - )) - }) - - It("should return the response", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - - body, err := ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(MatchJSON("[1,2,3]")) - }) - - It("should set the Content-Type header to application/json", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"})) - }) - }) - - Context("when optional headers are set", func() { - var headers http.Header - BeforeEach(func() { - headers = http.Header{"Stuff": []string{"things"}} - }) - - JustBeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithJSONEncoded(http.StatusCreated, []int{1, 2, 3}, headers), - )) - }) - - It("should preserve those headers", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Stuff"]).Should(Equal([]string{"things"})) - }) - - It("should set the Content-Type header to application/json", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"})) - }) - - Context("when setting the Content-Type explicitly", func() { - BeforeEach(func() { - headers["Content-Type"] = []string{"not-json"} - }) - - It("should use the Content-Type header that was explicitly set", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"not-json"})) - }) - }) - }) - }) - - Describe("RespondWithJSONPtr", func() { - type testObject struct { - Key string - Value string - } - - var code int - var object testObject - - Context("when no optional headers are set", func() { - BeforeEach(func() { - code = http.StatusOK - object = testObject{} - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithJSONEncodedPtr(&code, &object), - )) - }) - - It("should return the response", func() { - code = http.StatusCreated - object = testObject{ - Key: "Jim", - Value: "Codes", - } - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - - body, err := ioutil.ReadAll(resp.Body) - Expect(err).ShouldNot(HaveOccurred()) - Expect(body).Should(MatchJSON(`{"Key": "Jim", "Value": "Codes"}`)) - }) - - It("should set the Content-Type header to application/json", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"})) - }) - }) - - Context("when optional headers are set", func() { - var headers http.Header - BeforeEach(func() { - headers = http.Header{"Stuff": []string{"things"}} - }) - - JustBeforeEach(func() { - code = http.StatusOK - object = testObject{} - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/foo"), - RespondWithJSONEncodedPtr(&code, &object, headers), - )) - }) - - It("should preserve those headers", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Stuff"]).Should(Equal([]string{"things"})) - }) - - It("should set the Content-Type header to application/json", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"})) - }) - - Context("when setting the Content-Type explicitly", func() { - BeforeEach(func() { - headers["Content-Type"] = []string{"not-json"} - }) - - It("should use the Content-Type header that was explicitly set", func() { - resp, err = http.Post(s.URL()+"/foo", "application/json", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"not-json"})) - }) - }) - }) - }) - - Describe("RespondWithProto", func() { - var message *protobuf.SimpleMessage - - BeforeEach(func() { - message = new(protobuf.SimpleMessage) - message.Description = proto.String("A description") - message.Id = proto.Int32(99) - }) - - Context("when no optional headers are set", func() { - BeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/proto"), - RespondWithProto(http.StatusCreated, message), - )) - }) - - It("should return the response", func() { - resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - - var received protobuf.SimpleMessage - body, err := ioutil.ReadAll(resp.Body) - err = proto.Unmarshal(body, &received) - Expect(err).ShouldNot(HaveOccurred()) - }) - - It("should set the Content-Type header to application/x-protobuf", func() { - resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/x-protobuf"})) - }) - }) - - Context("when optional headers are set", func() { - var headers http.Header - BeforeEach(func() { - headers = http.Header{"Stuff": []string{"things"}} - }) - - JustBeforeEach(func() { - s.AppendHandlers(CombineHandlers( - VerifyRequest("POST", "/proto"), - RespondWithProto(http.StatusCreated, message, headers), - )) - }) - - It("should preserve those headers", func() { - resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Stuff"]).Should(Equal([]string{"things"})) - }) - - It("should set the Content-Type header to application/x-protobuf", func() { - resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/x-protobuf"})) - }) - - Context("when setting the Content-Type explicitly", func() { - BeforeEach(func() { - headers["Content-Type"] = []string{"not-x-protobuf"} - }) - - It("should use the Content-Type header that was explicitly set", func() { - resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil) - Expect(err).ShouldNot(HaveOccurred()) - - Expect(resp.Header["Content-Type"]).Should(Equal([]string{"not-x-protobuf"})) - }) - }) - }) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/go.mod b/vendor/github.com/onsi/gomega/go.mod deleted file mode 100644 index 65eedf6967..0000000000 --- a/vendor/github.com/onsi/gomega/go.mod +++ /dev/null @@ -1,15 +0,0 @@ -module github.com/onsi/gomega - -require ( - github.com/fsnotify/fsnotify v1.4.7 // indirect - github.com/golang/protobuf v1.2.0 - github.com/hpcloud/tail v1.0.0 // indirect - github.com/onsi/ginkgo v1.6.0 - golang.org/x/net v0.0.0-20180906233101-161cd47e91fd - golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect - golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e // indirect - golang.org/x/text v0.3.0 // indirect - gopkg.in/fsnotify.v1 v1.4.7 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/yaml.v2 v2.2.1 -) diff --git a/vendor/github.com/onsi/gomega/go.sum b/vendor/github.com/onsi/gomega/go.sum deleted file mode 100644 index b23f6ef028..0000000000 --- a/vendor/github.com/onsi/gomega/go.sum +++ /dev/null @@ -1,24 +0,0 @@ -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/onsi/gomega/gstruct/elements.go b/vendor/github.com/onsi/gomega/gstruct/elements.go deleted file mode 100644 index 13bf5b895a..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/elements.go +++ /dev/null @@ -1,159 +0,0 @@ -package gstruct - -import ( - "errors" - "fmt" - "reflect" - "runtime/debug" - - "github.com/onsi/gomega/format" - errorsutil "github.com/onsi/gomega/gstruct/errors" - "github.com/onsi/gomega/types" -) - -//MatchAllElements succeeds if every element of a slice matches the element matcher it maps to -//through the id function, and every element matcher is matched. -// idFn := func(element interface{}) string { -// return fmt.Sprintf("%v", element) -// } -// -// Expect([]string{"a", "b"}).To(MatchAllElements(idFn, Elements{ -// "a": Equal("a"), -// "b": Equal("b"), -// })) -func MatchAllElements(identifier Identifier, elements Elements) types.GomegaMatcher { - return &ElementsMatcher{ - Identifier: identifier, - Elements: elements, - } -} - -//MatchElements succeeds if each element of a slice matches the element matcher it maps to -//through the id function. It can ignore extra elements and/or missing elements. -// idFn := func(element interface{}) string { -// return fmt.Sprintf("%v", element) -// } -// -// Expect([]string{"a", "b", "c"}).To(MatchElements(idFn, IgnoreExtras, Elements{ -// "a": Equal("a"), -// "b": Equal("b"), -// })) -// Expect([]string{"a", "c"}).To(MatchElements(idFn, IgnoreMissing, Elements{ -// "a": Equal("a"), -// "b": Equal("b"), -// "c": Equal("c"), -// "d": Equal("d"), -// })) -func MatchElements(identifier Identifier, options Options, elements Elements) types.GomegaMatcher { - return &ElementsMatcher{ - Identifier: identifier, - Elements: elements, - IgnoreExtras: options&IgnoreExtras != 0, - IgnoreMissing: options&IgnoreMissing != 0, - AllowDuplicates: options&AllowDuplicates != 0, - } -} - -// ElementsMatcher is a NestingMatcher that applies custom matchers to each element of a slice mapped -// by the Identifier function. -// TODO: Extend this to work with arrays & maps (map the key) as well. -type ElementsMatcher struct { - // Matchers for each element. - Elements Elements - // Function mapping an element to the string key identifying its matcher. - Identifier Identifier - - // Whether to ignore extra elements or consider it an error. - IgnoreExtras bool - // Whether to ignore missing elements or consider it an error. - IgnoreMissing bool - // Whether to key duplicates when matching IDs. - AllowDuplicates bool - - // State. - failures []error -} - -// Element ID to matcher. -type Elements map[string]types.GomegaMatcher - -// Function for identifying (mapping) elements. -type Identifier func(element interface{}) string - -func (m *ElementsMatcher) Match(actual interface{}) (success bool, err error) { - if reflect.TypeOf(actual).Kind() != reflect.Slice { - return false, fmt.Errorf("%v is type %T, expected slice", actual, actual) - } - - m.failures = m.matchElements(actual) - if len(m.failures) > 0 { - return false, nil - } - return true, nil -} - -func (m *ElementsMatcher) matchElements(actual interface{}) (errs []error) { - // Provide more useful error messages in the case of a panic. - defer func() { - if err := recover(); err != nil { - errs = append(errs, fmt.Errorf("panic checking %+v: %v\n%s", actual, err, debug.Stack())) - } - }() - - val := reflect.ValueOf(actual) - elements := map[string]bool{} - for i := 0; i < val.Len(); i++ { - element := val.Index(i).Interface() - id := m.Identifier(element) - if elements[id] { - if !m.AllowDuplicates { - errs = append(errs, fmt.Errorf("found duplicate element ID %s", id)) - continue - } - } - elements[id] = true - - matcher, expected := m.Elements[id] - if !expected { - if !m.IgnoreExtras { - errs = append(errs, fmt.Errorf("unexpected element %s", id)) - } - continue - } - - match, err := matcher.Match(element) - if match { - continue - } - - if err == nil { - if nesting, ok := matcher.(errorsutil.NestingMatcher); ok { - err = errorsutil.AggregateError(nesting.Failures()) - } else { - err = errors.New(matcher.FailureMessage(element)) - } - } - errs = append(errs, errorsutil.Nest(fmt.Sprintf("[%s]", id), err)) - } - - for id := range m.Elements { - if !elements[id] && !m.IgnoreMissing { - errs = append(errs, fmt.Errorf("missing expected element %s", id)) - } - } - - return errs -} - -func (m *ElementsMatcher) FailureMessage(actual interface{}) (message string) { - failure := errorsutil.AggregateError(m.failures) - return format.Message(actual, fmt.Sprintf("to match elements: %v", failure)) -} - -func (m *ElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to match elements") -} - -func (m *ElementsMatcher) Failures() []error { - return m.failures -} diff --git a/vendor/github.com/onsi/gomega/gstruct/elements_test.go b/vendor/github.com/onsi/gomega/gstruct/elements_test.go deleted file mode 100644 index 355d463eb0..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/elements_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package gstruct_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gstruct" -) - -var _ = Describe("Slice", func() { - allElements := []string{"a", "b"} - missingElements := []string{"a"} - extraElements := []string{"a", "b", "c"} - duplicateElements := []string{"a", "a", "b"} - empty := []string{} - var nils []string - - It("should strictly match all elements", func() { - m := MatchAllElements(id, Elements{ - "b": Equal("b"), - "a": Equal("a"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(missingElements).ShouldNot(m, "should fail with missing elements") - Expect(extraElements).ShouldNot(m, "should fail with extra elements") - Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements") - Expect(nils).ShouldNot(m, "should fail with an uninitialized slice") - - m = MatchAllElements(id, Elements{ - "a": Equal("a"), - "b": Equal("fail"), - }) - Expect(allElements).ShouldNot(m, "should run nested matchers") - - m = MatchAllElements(id, Elements{}) - Expect(empty).Should(m, "should handle empty slices") - Expect(allElements).ShouldNot(m, "should handle only empty slices") - Expect(nils).Should(m, "should handle nil slices") - }) - - It("should ignore extra elements", func() { - m := MatchElements(id, IgnoreExtras, Elements{ - "b": Equal("b"), - "a": Equal("a"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(missingElements).ShouldNot(m, "should fail with missing elements") - Expect(extraElements).Should(m, "should ignore extra elements") - Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements") - Expect(nils).ShouldNot(m, "should fail with an uninitialized slice") - }) - - It("should ignore missing elements", func() { - m := MatchElements(id, IgnoreMissing, Elements{ - "a": Equal("a"), - "b": Equal("b"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(missingElements).Should(m, "should ignore missing elements") - Expect(extraElements).ShouldNot(m, "should fail with extra elements") - Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements") - Expect(nils).Should(m, "should ignore an uninitialized slice") - }) - - It("should ignore missing and extra elements", func() { - m := MatchElements(id, IgnoreMissing|IgnoreExtras, Elements{ - "a": Equal("a"), - "b": Equal("b"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(missingElements).Should(m, "should ignore missing elements") - Expect(extraElements).Should(m, "should ignore extra elements") - Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements") - Expect(nils).Should(m, "should ignore an uninitialized slice") - - m = MatchElements(id, IgnoreExtras|IgnoreMissing, Elements{ - "a": Equal("a"), - "b": Equal("fail"), - }) - Expect(allElements).ShouldNot(m, "should run nested matchers") - }) - - Context("with elements that share a key", func() { - nonUniqueID := func(element interface{}) string { - return element.(string)[0:1] - } - - allElements := []string{"a123", "a213", "b321"} - includingBadElements := []string{"a123", "b123", "b5555"} - extraElements := []string{"a123", "b1234", "c345"} - missingElements := []string{"b123", "b1234", "b1345"} - - It("should strictly allow multiple matches", func() { - m := MatchElements(nonUniqueID, AllowDuplicates, Elements{ - "a": ContainSubstring("1"), - "b": ContainSubstring("1"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher") - Expect(extraElements).ShouldNot(m, "should reject with extra keys") - Expect(missingElements).ShouldNot(m, "should reject with missing keys") - Expect(nils).ShouldNot(m, "should fail with an uninitialized slice") - }) - - It("should ignore missing", func() { - m := MatchElements(nonUniqueID, AllowDuplicates|IgnoreMissing, Elements{ - "a": ContainSubstring("1"), - "b": ContainSubstring("1"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher") - Expect(extraElements).ShouldNot(m, "should reject with extra keys") - Expect(missingElements).Should(m, "should allow missing keys") - Expect(nils).Should(m, "should allow an uninitialized slice") - }) - - It("should ignore extras", func() { - m := MatchElements(nonUniqueID, AllowDuplicates|IgnoreExtras, Elements{ - "a": ContainSubstring("1"), - "b": ContainSubstring("1"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher") - Expect(extraElements).Should(m, "should allow extra keys") - Expect(missingElements).ShouldNot(m, "should reject missing keys") - Expect(nils).ShouldNot(m, "should reject an uninitialized slice") - }) - - It("should ignore missing and extras", func() { - m := MatchElements(nonUniqueID, AllowDuplicates|IgnoreExtras|IgnoreMissing, Elements{ - "a": ContainSubstring("1"), - "b": ContainSubstring("1"), - }) - Expect(allElements).Should(m, "should match all elements") - Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher") - Expect(extraElements).Should(m, "should allow extra keys") - Expect(missingElements).Should(m, "should allow missing keys") - Expect(nils).Should(m, "should allow an uninitialized slice") - }) - }) -}) - -func id(element interface{}) string { - return element.(string) -} diff --git a/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go b/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go deleted file mode 100644 index 188492b212..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go +++ /dev/null @@ -1,72 +0,0 @@ -package errors - -import ( - "fmt" - "strings" - - "github.com/onsi/gomega/types" -) - -// A stateful matcher that nests other matchers within it and preserves the error types of the -// nested matcher failures. -type NestingMatcher interface { - types.GomegaMatcher - - // Returns the failures of nested matchers. - Failures() []error -} - -// An error type for labeling errors on deeply nested matchers. -type NestedError struct { - Path string - Err error -} - -func (e *NestedError) Error() string { - // Indent Errors. - indented := strings.Replace(e.Err.Error(), "\n", "\n\t", -1) - return fmt.Sprintf("%s:\n\t%v", e.Path, indented) -} - -// Create a NestedError with the given path. -// If err is a NestedError, prepend the path to it. -// If err is an AggregateError, recursively Nest each error. -func Nest(path string, err error) error { - if ag, ok := err.(AggregateError); ok { - var errs AggregateError - for _, e := range ag { - errs = append(errs, Nest(path, e)) - } - return errs - } - if ne, ok := err.(*NestedError); ok { - return &NestedError{ - Path: path + ne.Path, - Err: ne.Err, - } - } - return &NestedError{ - Path: path, - Err: err, - } -} - -// An error type for treating multiple errors as a single error. -type AggregateError []error - -// Error is part of the error interface. -func (err AggregateError) Error() string { - if len(err) == 0 { - // This should never happen, really. - return "" - } - if len(err) == 1 { - return err[0].Error() - } - result := fmt.Sprintf("[%s", err[0].Error()) - for i := 1; i < len(err); i++ { - result += fmt.Sprintf(", %s", err[i].Error()) - } - result += "]" - return result -} diff --git a/vendor/github.com/onsi/gomega/gstruct/fields.go b/vendor/github.com/onsi/gomega/gstruct/fields.go deleted file mode 100644 index 2eb2d08871..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/fields.go +++ /dev/null @@ -1,168 +0,0 @@ -package gstruct - -import ( - "errors" - "fmt" - "reflect" - "runtime/debug" - "strings" - - "github.com/onsi/gomega/format" - errorsutil "github.com/onsi/gomega/gstruct/errors" - "github.com/onsi/gomega/types" -) - -//MatchAllFields succeeds if every field of a struct matches the field matcher associated with -//it, and every element matcher is matched. -// actual := struct{ -// A int -// B []bool -// C string -// }{ -// A: 5, -// B: []bool{true, false}, -// C: "foo", -// } -// -// Expect(actual).To(MatchAllFields(Fields{ -// "A": Equal(5), -// "B": ConsistOf(true, false), -// "C": Equal("foo"), -// })) -func MatchAllFields(fields Fields) types.GomegaMatcher { - return &FieldsMatcher{ - Fields: fields, - } -} - -//MatchFields succeeds if each element of a struct matches the field matcher associated with -//it. It can ignore extra fields and/or missing fields. -// actual := struct{ -// A int -// B []bool -// C string -// }{ -// A: 5, -// B: []bool{true, false}, -// C: "foo", -// } -// -// Expect(actual).To(MatchFields(IgnoreExtras, Fields{ -// "A": Equal(5), -// "B": ConsistOf(true, false), -// })) -// Expect(actual).To(MatchFields(IgnoreMissing, Fields{ -// "A": Equal(5), -// "B": ConsistOf(true, false), -// "C": Equal("foo"), -// "D": Equal("extra"), -// })) -func MatchFields(options Options, fields Fields) types.GomegaMatcher { - return &FieldsMatcher{ - Fields: fields, - IgnoreExtras: options&IgnoreExtras != 0, - IgnoreMissing: options&IgnoreMissing != 0, - } -} - -type FieldsMatcher struct { - // Matchers for each field. - Fields Fields - - // Whether to ignore extra elements or consider it an error. - IgnoreExtras bool - // Whether to ignore missing elements or consider it an error. - IgnoreMissing bool - - // State. - failures []error -} - -// Field name to matcher. -type Fields map[string]types.GomegaMatcher - -func (m *FieldsMatcher) Match(actual interface{}) (success bool, err error) { - if reflect.TypeOf(actual).Kind() != reflect.Struct { - return false, fmt.Errorf("%v is type %T, expected struct", actual, actual) - } - - m.failures = m.matchFields(actual) - if len(m.failures) > 0 { - return false, nil - } - return true, nil -} - -func (m *FieldsMatcher) matchFields(actual interface{}) (errs []error) { - val := reflect.ValueOf(actual) - typ := val.Type() - fields := map[string]bool{} - for i := 0; i < val.NumField(); i++ { - fieldName := typ.Field(i).Name - fields[fieldName] = true - - err := func() (err error) { - // This test relies heavily on reflect, which tends to panic. - // Recover here to provide more useful error messages in that case. - defer func() { - if r := recover(); r != nil { - err = fmt.Errorf("panic checking %+v: %v\n%s", actual, r, debug.Stack()) - } - }() - - matcher, expected := m.Fields[fieldName] - if !expected { - if !m.IgnoreExtras { - return fmt.Errorf("unexpected field %s: %+v", fieldName, actual) - } - return nil - } - - var field interface{} - if val.Field(i).IsValid() { - field = val.Field(i).Interface() - } else { - field = reflect.Zero(typ.Field(i).Type) - } - - match, err := matcher.Match(field) - if err != nil { - return err - } else if !match { - if nesting, ok := matcher.(errorsutil.NestingMatcher); ok { - return errorsutil.AggregateError(nesting.Failures()) - } - return errors.New(matcher.FailureMessage(field)) - } - return nil - }() - if err != nil { - errs = append(errs, errorsutil.Nest("."+fieldName, err)) - } - } - - for field := range m.Fields { - if !fields[field] && !m.IgnoreMissing { - errs = append(errs, fmt.Errorf("missing expected field %s", field)) - } - } - - return errs -} - -func (m *FieldsMatcher) FailureMessage(actual interface{}) (message string) { - failures := make([]string, len(m.failures)) - for i := range m.failures { - failures[i] = m.failures[i].Error() - } - return format.Message(reflect.TypeOf(actual).Name(), - fmt.Sprintf("to match fields: {\n%v\n}\n", strings.Join(failures, "\n"))) -} - -func (m *FieldsMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to match fields") -} - -func (m *FieldsMatcher) Failures() []error { - return m.failures -} diff --git a/vendor/github.com/onsi/gomega/gstruct/fields_test.go b/vendor/github.com/onsi/gomega/gstruct/fields_test.go deleted file mode 100644 index e4e039e219..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/fields_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package gstruct_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gstruct" -) - -var _ = Describe("Struct", func() { - allFields := struct{ A, B string }{"a", "b"} - missingFields := struct{ A string }{"a"} - extraFields := struct{ A, B, C string }{"a", "b", "c"} - emptyFields := struct{ A, B string }{} - - It("should strictly match all fields", func() { - m := MatchAllFields(Fields{ - "B": Equal("b"), - "A": Equal("a"), - }) - Expect(allFields).Should(m, "should match all fields") - Expect(missingFields).ShouldNot(m, "should fail with missing fields") - Expect(extraFields).ShouldNot(m, "should fail with extra fields") - Expect(emptyFields).ShouldNot(m, "should fail with empty fields") - - m = MatchAllFields(Fields{ - "A": Equal("a"), - "B": Equal("fail"), - }) - Expect(allFields).ShouldNot(m, "should run nested matchers") - }) - - It("should handle empty structs", func() { - m := MatchAllFields(Fields{}) - Expect(struct{}{}).Should(m, "should handle empty structs") - Expect(allFields).ShouldNot(m, "should fail with extra fields") - }) - - It("should ignore missing fields", func() { - m := MatchFields(IgnoreMissing, Fields{ - "B": Equal("b"), - "A": Equal("a"), - }) - Expect(allFields).Should(m, "should match all fields") - Expect(missingFields).Should(m, "should ignore missing fields") - Expect(extraFields).ShouldNot(m, "should fail with extra fields") - Expect(emptyFields).ShouldNot(m, "should fail with empty fields") - }) - - It("should ignore extra fields", func() { - m := MatchFields(IgnoreExtras, Fields{ - "B": Equal("b"), - "A": Equal("a"), - }) - Expect(allFields).Should(m, "should match all fields") - Expect(missingFields).ShouldNot(m, "should fail with missing fields") - Expect(extraFields).Should(m, "should ignore extra fields") - Expect(emptyFields).ShouldNot(m, "should fail with empty fields") - }) - - It("should ignore missing and extra fields", func() { - m := MatchFields(IgnoreMissing|IgnoreExtras, Fields{ - "B": Equal("b"), - "A": Equal("a"), - }) - Expect(allFields).Should(m, "should match all fields") - Expect(missingFields).Should(m, "should ignore missing fields") - Expect(extraFields).Should(m, "should ignore extra fields") - Expect(emptyFields).ShouldNot(m, "should fail with empty fields") - - m = MatchFields(IgnoreMissing|IgnoreExtras, Fields{ - "A": Equal("a"), - "B": Equal("fail"), - }) - Expect(allFields).ShouldNot(m, "should run nested matchers") - }) -}) diff --git a/vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go b/vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go deleted file mode 100644 index d475663040..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package gstruct_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func Test(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Gstruct Suite") -} diff --git a/vendor/github.com/onsi/gomega/gstruct/ignore.go b/vendor/github.com/onsi/gomega/gstruct/ignore.go deleted file mode 100644 index 0365f32ad1..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/ignore.go +++ /dev/null @@ -1,37 +0,0 @@ -package gstruct - -import ( - "github.com/onsi/gomega/types" -) - -//Ignore ignores the actual value and always succeeds. -// Expect(nil).To(Ignore()) -// Expect(true).To(Ignore()) -func Ignore() types.GomegaMatcher { - return &IgnoreMatcher{true} -} - -//Reject ignores the actual value and always fails. It can be used in conjunction with IgnoreMissing -//to catch problematic elements, or to verify tests are running. -// Expect(nil).NotTo(Reject()) -// Expect(true).NotTo(Reject()) -func Reject() types.GomegaMatcher { - return &IgnoreMatcher{false} -} - -// A matcher that either always succeeds or always fails. -type IgnoreMatcher struct { - Succeed bool -} - -func (m *IgnoreMatcher) Match(actual interface{}) (bool, error) { - return m.Succeed, nil -} - -func (m *IgnoreMatcher) FailureMessage(_ interface{}) (message string) { - return "Unconditional failure" -} - -func (m *IgnoreMatcher) NegatedFailureMessage(_ interface{}) (message string) { - return "Unconditional success" -} diff --git a/vendor/github.com/onsi/gomega/gstruct/ignore_test.go b/vendor/github.com/onsi/gomega/gstruct/ignore_test.go deleted file mode 100644 index 07775e742e..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/ignore_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package gstruct_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gstruct" -) - -var _ = Describe("Ignore", func() { - It("should always succeed", func() { - Expect(nil).Should(Ignore()) - Expect(struct{}{}).Should(Ignore()) - Expect(0).Should(Ignore()) - Expect(false).Should(Ignore()) - }) - - It("should always fail", func() { - Expect(nil).ShouldNot(Reject()) - Expect(struct{}{}).ShouldNot(Reject()) - Expect(1).ShouldNot(Reject()) - Expect(true).ShouldNot(Reject()) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gstruct/pointer.go b/vendor/github.com/onsi/gomega/gstruct/pointer.go deleted file mode 100644 index 0a2f35de31..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/pointer.go +++ /dev/null @@ -1,56 +0,0 @@ -package gstruct - -import ( - "fmt" - "reflect" - - "github.com/onsi/gomega/format" - "github.com/onsi/gomega/types" -) - -//PointTo applies the given matcher to the value pointed to by actual. It fails if the pointer is -//nil. -// actual := 5 -// Expect(&actual).To(PointTo(Equal(5))) -func PointTo(matcher types.GomegaMatcher) types.GomegaMatcher { - return &PointerMatcher{ - Matcher: matcher, - } -} - -type PointerMatcher struct { - Matcher types.GomegaMatcher - - // Failure message. - failure string -} - -func (m *PointerMatcher) Match(actual interface{}) (bool, error) { - val := reflect.ValueOf(actual) - - // return error if actual type is not a pointer - if val.Kind() != reflect.Ptr { - return false, fmt.Errorf("PointerMatcher expects a pointer but we have '%s'", val.Kind()) - } - - if !val.IsValid() || val.IsNil() { - m.failure = format.Message(actual, "not to be ") - return false, nil - } - - // Forward the value. - elem := val.Elem().Interface() - match, err := m.Matcher.Match(elem) - if !match { - m.failure = m.Matcher.FailureMessage(elem) - } - return match, err -} - -func (m *PointerMatcher) FailureMessage(_ interface{}) (message string) { - return m.failure -} - -func (m *PointerMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return m.Matcher.NegatedFailureMessage(actual) -} diff --git a/vendor/github.com/onsi/gomega/gstruct/pointer_test.go b/vendor/github.com/onsi/gomega/gstruct/pointer_test.go deleted file mode 100644 index 805a92abe7..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/pointer_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package gstruct_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gstruct" -) - -var _ = Describe("PointTo", func() { - It("should fail when passed nil", func() { - var p *struct{} - Expect(p).Should(BeNil()) - }) - - It("should succeed when passed non-nil pointer", func() { - var s struct{} - Expect(&s).Should(PointTo(Ignore())) - }) - - It("should unwrap the pointee value", func() { - i := 1 - Expect(&i).Should(PointTo(Equal(1))) - Expect(&i).ShouldNot(PointTo(Equal(2))) - }) - - It("should work with nested pointers", func() { - i := 1 - ip := &i - ipp := &ip - Expect(ipp).Should(PointTo(PointTo(Equal(1)))) - Expect(ipp).ShouldNot(PointTo(PointTo(Equal(2)))) - }) -}) diff --git a/vendor/github.com/onsi/gomega/gstruct/types.go b/vendor/github.com/onsi/gomega/gstruct/types.go deleted file mode 100644 index 48cbbe8f66..0000000000 --- a/vendor/github.com/onsi/gomega/gstruct/types.go +++ /dev/null @@ -1,15 +0,0 @@ -package gstruct - -//Options is the type for options passed to some matchers. -type Options int - -const ( - //IgnoreExtras tells the matcher to ignore extra elements or fields, rather than triggering a failure. - IgnoreExtras Options = 1 << iota - //IgnoreMissing tells the matcher to ignore missing elements or fields, rather than triggering a failure. - IgnoreMissing - //AllowDuplicates tells the matcher to permit multiple members of the slice to produce the same ID when - //considered by the indentifier function. All members that map to a given key must still match successfully - //with the matcher that is provided for that key. - AllowDuplicates -) diff --git a/vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go b/vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go deleted file mode 100644 index dae47a48bf..0000000000 --- a/vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package assertion_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestAssertion(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Assertion Suite") -} diff --git a/vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go b/vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go deleted file mode 100644 index cac0d24c5b..0000000000 --- a/vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go +++ /dev/null @@ -1,258 +0,0 @@ -package assertion_test - -import ( - "errors" - - "github.com/onsi/gomega/internal/testingtsupport" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/internal/assertion" - "github.com/onsi/gomega/internal/fakematcher" - "github.com/onsi/gomega/types" -) - -var _ = Describe("Assertion", func() { - var ( - a *Assertion - failureMessage string - failureCallerSkip int - matcher *fakematcher.FakeMatcher - ) - - input := "The thing I'm testing" - - var fakeFailWrapper = &types.GomegaFailWrapper{ - Fail: func(message string, callerSkip ...int) { - failureMessage = message - if len(callerSkip) == 1 { - failureCallerSkip = callerSkip[0] - } - }, - TWithHelper: testingtsupport.EmptyTWithHelper{}, - } - - BeforeEach(func() { - matcher = &fakematcher.FakeMatcher{} - failureMessage = "" - failureCallerSkip = 0 - a = New(input, fakeFailWrapper, 1) - }) - - Context("when called", func() { - It("should pass the provided input value to the matcher", func() { - a.Should(matcher) - - Expect(matcher.ReceivedActual).Should(Equal(input)) - matcher.ReceivedActual = "" - - a.ShouldNot(matcher) - - Expect(matcher.ReceivedActual).Should(Equal(input)) - matcher.ReceivedActual = "" - - a.To(matcher) - - Expect(matcher.ReceivedActual).Should(Equal(input)) - matcher.ReceivedActual = "" - - a.ToNot(matcher) - - Expect(matcher.ReceivedActual).Should(Equal(input)) - matcher.ReceivedActual = "" - - a.NotTo(matcher) - - Expect(matcher.ReceivedActual).Should(Equal(input)) - }) - }) - - Context("when the matcher succeeds", func() { - BeforeEach(func() { - matcher.MatchesToReturn = true - matcher.ErrToReturn = nil - }) - - Context("and a positive assertion is being made", func() { - It("should not call the failure callback", func() { - a.Should(matcher) - Expect(failureMessage).Should(Equal("")) - }) - - It("should be true", func() { - Expect(a.Should(matcher)).Should(BeTrue()) - }) - }) - - Context("and a negative assertion is being made", func() { - It("should call the failure callback", func() { - a.ShouldNot(matcher) - Expect(failureMessage).Should(Equal("negative: The thing I'm testing")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - - It("should be false", func() { - Expect(a.ShouldNot(matcher)).Should(BeFalse()) - }) - }) - }) - - Context("when the matcher fails", func() { - BeforeEach(func() { - matcher.MatchesToReturn = false - matcher.ErrToReturn = nil - }) - - Context("and a positive assertion is being made", func() { - It("should call the failure callback", func() { - a.Should(matcher) - Expect(failureMessage).Should(Equal("positive: The thing I'm testing")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - - It("should be false", func() { - Expect(a.Should(matcher)).Should(BeFalse()) - }) - }) - - Context("and a negative assertion is being made", func() { - It("should not call the failure callback", func() { - a.ShouldNot(matcher) - Expect(failureMessage).Should(Equal("")) - }) - - It("should be true", func() { - Expect(a.ShouldNot(matcher)).Should(BeTrue()) - }) - }) - }) - - Context("When reporting a failure", func() { - BeforeEach(func() { - matcher.MatchesToReturn = false - matcher.ErrToReturn = nil - }) - - Context("and there is an optional description", func() { - It("should append the description to the failure message", func() { - a.Should(matcher, "A description") - Expect(failureMessage).Should(Equal("A description\npositive: The thing I'm testing")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - }) - - Context("and there are multiple arguments to the optional description", func() { - It("should append the formatted description to the failure message", func() { - a.Should(matcher, "A description of [%d]", 3) - Expect(failureMessage).Should(Equal("A description of [3]\npositive: The thing I'm testing")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - }) - }) - - Context("When the matcher returns an error", func() { - BeforeEach(func() { - matcher.ErrToReturn = errors.New("Kaboom!") - }) - - Context("and a positive assertion is being made", func() { - It("should call the failure callback", func() { - matcher.MatchesToReturn = true - a.Should(matcher) - Expect(failureMessage).Should(Equal("Kaboom!")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - }) - - Context("and a negative assertion is being made", func() { - It("should call the failure callback", func() { - matcher.MatchesToReturn = false - a.ShouldNot(matcher) - Expect(failureMessage).Should(Equal("Kaboom!")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - }) - - It("should always be false", func() { - Expect(a.Should(matcher)).Should(BeFalse()) - Expect(a.ShouldNot(matcher)).Should(BeFalse()) - }) - }) - - Context("when there are extra parameters", func() { - It("(a simple example)", func() { - Expect(func() (string, int, error) { - return "foo", 0, nil - }()).Should(Equal("foo")) - }) - - Context("when the parameters are all nil or zero", func() { - It("should invoke the matcher", func() { - matcher.MatchesToReturn = true - matcher.ErrToReturn = nil - - var typedNil []string - a = New(input, fakeFailWrapper, 1, 0, nil, typedNil) - - result := a.Should(matcher) - Expect(result).Should(BeTrue()) - Expect(matcher.ReceivedActual).Should(Equal(input)) - - Expect(failureMessage).Should(BeZero()) - }) - }) - - Context("when any of the parameters are not nil or zero", func() { - It("should call the failure callback", func() { - matcher.MatchesToReturn = false - matcher.ErrToReturn = nil - - a = New(input, fakeFailWrapper, 1, errors.New("foo")) - result := a.Should(matcher) - Expect(result).Should(BeFalse()) - Expect(matcher.ReceivedActual).Should(BeZero(), "The matcher doesn't even get called") - Expect(failureMessage).Should(ContainSubstring("foo")) - failureMessage = "" - - a = New(input, fakeFailWrapper, 1, nil, 1) - result = a.ShouldNot(matcher) - Expect(result).Should(BeFalse()) - Expect(failureMessage).Should(ContainSubstring("1")) - failureMessage = "" - - a = New(input, fakeFailWrapper, 1, nil, 0, []string{"foo"}) - result = a.To(matcher) - Expect(result).Should(BeFalse()) - Expect(failureMessage).Should(ContainSubstring("foo")) - failureMessage = "" - - a = New(input, fakeFailWrapper, 1, nil, 0, []string{"foo"}) - result = a.ToNot(matcher) - Expect(result).Should(BeFalse()) - Expect(failureMessage).Should(ContainSubstring("foo")) - failureMessage = "" - - a = New(input, fakeFailWrapper, 1, nil, 0, []string{"foo"}) - result = a.NotTo(matcher) - Expect(result).Should(BeFalse()) - Expect(failureMessage).Should(ContainSubstring("foo")) - Expect(failureCallerSkip).Should(Equal(3)) - }) - }) - }) - - Context("Making an assertion without a registered fail handler", func() { - It("should panic", func() { - defer func() { - e := recover() - RegisterFailHandler(Fail) - if e == nil { - Fail("expected a panic to have occurred") - } - }() - - RegisterFailHandler(nil) - Expect(true).Should(BeTrue()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go deleted file mode 100644 index bdb0c3d220..0000000000 --- a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package asyncassertion_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestAsyncAssertion(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "AsyncAssertion Suite") -} diff --git a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go deleted file mode 100644 index afd61a7cdd..0000000000 --- a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go +++ /dev/null @@ -1,351 +0,0 @@ -package asyncassertion_test - -import ( - "errors" - "time" - - "github.com/onsi/gomega/internal/testingtsupport" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/internal/asyncassertion" - "github.com/onsi/gomega/types" -) - -var _ = Describe("Async Assertion", func() { - var ( - failureMessage string - callerSkip int - ) - - var fakeFailWrapper = &types.GomegaFailWrapper{ - Fail: func(message string, skip ...int) { - failureMessage = message - callerSkip = skip[0] - }, - TWithHelper: testingtsupport.EmptyTWithHelper{}, - } - - BeforeEach(func() { - failureMessage = "" - callerSkip = 0 - }) - - Describe("Eventually", func() { - Context("the positive case", func() { - It("should poll the function and matcher", func() { - counter := 0 - a := New(AsyncAssertionTypeEventually, func() int { - counter++ - return counter - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.Should(BeNumerically("==", 5)) - Expect(failureMessage).Should(BeZero()) - }) - - It("should continue when the matcher errors", func() { - counter := 0 - a := New(AsyncAssertionTypeEventually, func() interface{} { - counter++ - if counter == 5 { - return "not-a-number" //this should cause the matcher to error - } - return counter - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.Should(BeNumerically("==", 5), "My description %d", 2) - - Expect(failureMessage).Should(ContainSubstring("Timed out after")) - Expect(failureMessage).Should(ContainSubstring("My description 2")) - Expect(callerSkip).Should(Equal(4)) - }) - - It("should be able to timeout", func() { - counter := 0 - a := New(AsyncAssertionTypeEventually, func() int { - counter++ - return counter - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.Should(BeNumerically(">", 100), "My description %d", 2) - - Expect(counter).Should(BeNumerically(">", 8)) - Expect(counter).Should(BeNumerically("<=", 10)) - Expect(failureMessage).Should(ContainSubstring("Timed out after")) - Expect(failureMessage).Should(MatchRegexp(`\: \d`), "Should pass the correct value to the matcher message formatter.") - Expect(failureMessage).Should(ContainSubstring("My description 2")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - - Context("the negative case", func() { - It("should poll the function and matcher", func() { - counter := 0 - a := New(AsyncAssertionTypeEventually, func() int { - counter += 1 - return counter - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.ShouldNot(BeNumerically("<", 3)) - - Expect(counter).Should(Equal(3)) - Expect(failureMessage).Should(BeZero()) - }) - - It("should timeout when the matcher errors", func() { - a := New(AsyncAssertionTypeEventually, func() interface{} { - return 0 //this should cause the matcher to error - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.ShouldNot(HaveLen(0), "My description %d", 2) - - Expect(failureMessage).Should(ContainSubstring("Timed out after")) - Expect(failureMessage).Should(ContainSubstring("Error:")) - Expect(failureMessage).Should(ContainSubstring("My description 2")) - Expect(callerSkip).Should(Equal(4)) - }) - - It("should be able to timeout", func() { - a := New(AsyncAssertionTypeEventually, func() int { - return 0 - }, fakeFailWrapper, time.Duration(0.1*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.ShouldNot(Equal(0), "My description %d", 2) - - Expect(failureMessage).Should(ContainSubstring("Timed out after")) - Expect(failureMessage).Should(ContainSubstring(": 0"), "Should pass the correct value to the matcher message formatter.") - Expect(failureMessage).Should(ContainSubstring("My description 2")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - - Context("with a function that returns multiple values", func() { - It("should eventually succeed if the additional arguments are nil", func() { - i := 0 - Eventually(func() (int, error) { - i++ - return i, nil - }).Should(Equal(10)) - }) - - It("should eventually timeout if the additional arguments are not nil", func() { - i := 0 - a := New(AsyncAssertionTypeEventually, func() (int, error) { - i++ - return i, errors.New("bam") - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - a.Should(Equal(2)) - - Expect(failureMessage).Should(ContainSubstring("Timed out after")) - Expect(failureMessage).Should(ContainSubstring("Error:")) - Expect(failureMessage).Should(ContainSubstring("bam")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - - Context("Making an assertion without a registered fail handler", func() { - It("should panic", func() { - defer func() { - e := recover() - RegisterFailHandler(Fail) - if e == nil { - Fail("expected a panic to have occurred") - } - }() - - RegisterFailHandler(nil) - c := make(chan bool, 1) - c <- true - Eventually(c).Should(Receive()) - }) - }) - }) - - Describe("Consistently", func() { - Describe("The positive case", func() { - Context("when the matcher consistently passes for the duration", func() { - It("should pass", func() { - calls := 0 - a := New(AsyncAssertionTypeConsistently, func() string { - calls++ - return "foo" - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.Should(Equal("foo")) - Expect(calls).Should(BeNumerically(">", 8)) - Expect(calls).Should(BeNumerically("<=", 10)) - Expect(failureMessage).Should(BeZero()) - }) - }) - - Context("when the matcher fails at some point", func() { - It("should fail", func() { - calls := 0 - a := New(AsyncAssertionTypeConsistently, func() interface{} { - calls++ - if calls > 5 { - return "bar" - } - return "foo" - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.Should(Equal("foo")) - Expect(failureMessage).Should(ContainSubstring("to equal")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - - Context("when the matcher errors at some point", func() { - It("should fail", func() { - calls := 0 - a := New(AsyncAssertionTypeConsistently, func() interface{} { - calls++ - if calls > 5 { - return 3 - } - return []int{1, 2, 3} - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.Should(HaveLen(3)) - Expect(failureMessage).Should(ContainSubstring("HaveLen matcher expects")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - }) - - Describe("The negative case", func() { - Context("when the matcher consistently passes for the duration", func() { - It("should pass", func() { - c := make(chan bool) - a := New(AsyncAssertionTypeConsistently, c, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.ShouldNot(Receive()) - Expect(failureMessage).Should(BeZero()) - }) - }) - - Context("when the matcher fails at some point", func() { - It("should fail", func() { - c := make(chan bool) - go func() { - time.Sleep(time.Duration(100 * time.Millisecond)) - c <- true - }() - - a := New(AsyncAssertionTypeConsistently, c, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.ShouldNot(Receive()) - Expect(failureMessage).Should(ContainSubstring("not to receive anything")) - }) - }) - - Context("when the matcher errors at some point", func() { - It("should fail", func() { - calls := 0 - a := New(AsyncAssertionTypeConsistently, func() interface{} { - calls++ - return calls - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - - a.ShouldNot(BeNumerically(">", 5)) - Expect(failureMessage).Should(ContainSubstring("not to be >")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - }) - - Context("with a function that returns multiple values", func() { - It("should consistently succeed if the additional arguments are nil", func() { - i := 2 - Consistently(func() (int, error) { - i++ - return i, nil - }).Should(BeNumerically(">=", 2)) - }) - - It("should eventually timeout if the additional arguments are not nil", func() { - i := 2 - a := New(AsyncAssertionTypeEventually, func() (int, error) { - i++ - return i, errors.New("bam") - }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1) - a.Should(BeNumerically(">=", 2)) - - Expect(failureMessage).Should(ContainSubstring("Error:")) - Expect(failureMessage).Should(ContainSubstring("bam")) - Expect(callerSkip).Should(Equal(4)) - }) - }) - - Context("Making an assertion without a registered fail handler", func() { - It("should panic", func() { - defer func() { - e := recover() - RegisterFailHandler(Fail) - if e == nil { - Fail("expected a panic to have occurred") - } - }() - - RegisterFailHandler(nil) - c := make(chan bool) - Consistently(c).ShouldNot(Receive()) - }) - }) - }) - - Context("when passed a function with the wrong # or arguments & returns", func() { - It("should panic", func() { - Expect(func() { - New(AsyncAssertionTypeEventually, func() {}, fakeFailWrapper, 0, 0, 1) - }).Should(Panic()) - - Expect(func() { - New(AsyncAssertionTypeEventually, func(a string) int { return 0 }, fakeFailWrapper, 0, 0, 1) - }).Should(Panic()) - - Expect(func() { - New(AsyncAssertionTypeEventually, func() int { return 0 }, fakeFailWrapper, 0, 0, 1) - }).ShouldNot(Panic()) - - Expect(func() { - New(AsyncAssertionTypeEventually, func() (int, error) { return 0, nil }, fakeFailWrapper, 0, 0, 1) - }).ShouldNot(Panic()) - }) - }) - - Describe("bailing early", func() { - Context("when actual is a value", func() { - It("Eventually should bail out and fail early if the matcher says to", func() { - c := make(chan bool) - close(c) - - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(c, 0.1).Should(Receive()) - }) - Expect(time.Since(t)).Should(BeNumerically("<", 90*time.Millisecond)) - - Expect(failures).Should(HaveLen(1)) - }) - }) - - Context("when actual is a function", func() { - It("should never bail early", func() { - c := make(chan bool) - close(c) - - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(func() chan bool { - return c - }, 0.1).Should(Receive()) - }) - Expect(time.Since(t)).Should(BeNumerically(">=", 90*time.Millisecond)) - - Expect(failures).Should(HaveLen(1)) - }) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go b/vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go deleted file mode 100644 index 6e351a7de5..0000000000 --- a/vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go +++ /dev/null @@ -1,23 +0,0 @@ -package fakematcher - -import "fmt" - -type FakeMatcher struct { - ReceivedActual interface{} - MatchesToReturn bool - ErrToReturn error -} - -func (matcher *FakeMatcher) Match(actual interface{}) (bool, error) { - matcher.ReceivedActual = actual - - return matcher.MatchesToReturn, matcher.ErrToReturn -} - -func (matcher *FakeMatcher) FailureMessage(actual interface{}) string { - return fmt.Sprintf("positive: %v", actual) -} - -func (matcher *FakeMatcher) NegatedFailureMessage(actual interface{}) string { - return fmt.Sprintf("negative: %v", actual) -} diff --git a/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go b/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go deleted file mode 100644 index 8fd8f0a6c2..0000000000 --- a/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package testingtsupport_test - -import ( - "regexp" - "time" - - "github.com/onsi/gomega/internal/testingtsupport" - - . "github.com/onsi/gomega" - - "fmt" - "testing" -) - -func TestTestingT(t *testing.T) { - RegisterTestingT(t) - Ω(true).Should(BeTrue()) -} - -type FakeTWithHelper struct { - LastFatal string -} - -func (f *FakeTWithHelper) Fatalf(format string, args ...interface{}) { - f.LastFatal = fmt.Sprintf(format, args...) -} - -func TestGomegaWithTWithoutHelper(t *testing.T) { - g := NewGomegaWithT(t) - - testingtsupport.StackTracePruneRE = regexp.MustCompile(`\/ginkgo\/`) - - f := &FakeTWithHelper{} - testG := NewGomegaWithT(f) - - testG.Expect("foo").To(Equal("foo")) - g.Expect(f.LastFatal).To(BeZero()) - - testG.Expect("foo").To(Equal("bar")) - g.Expect(f.LastFatal).To(ContainSubstring(": foo")) - g.Expect(f.LastFatal).To(ContainSubstring("testingtsupport_test"), "It should include a stacktrace") - - testG.Eventually("foo2", time.Millisecond).Should(Equal("bar")) - g.Expect(f.LastFatal).To(ContainSubstring(": foo2")) - - testG.Consistently("foo3", time.Millisecond).Should(Equal("bar")) - g.Expect(f.LastFatal).To(ContainSubstring(": foo3")) -} - -type FakeTWithoutHelper struct { - LastFatal string - HelperCount int -} - -func (f *FakeTWithoutHelper) Fatalf(format string, args ...interface{}) { - f.LastFatal = fmt.Sprintf(format, args...) -} - -func (f *FakeTWithoutHelper) Helper() { - f.HelperCount += 1 -} - -func (f *FakeTWithoutHelper) ResetHelper() { - f.HelperCount = 0 -} - -func TestGomegaWithTWithHelper(t *testing.T) { - g := NewGomegaWithT(t) - - f := &FakeTWithoutHelper{} - testG := NewGomegaWithT(f) - - testG.Expect("foo").To(Equal("foo")) - g.Expect(f.LastFatal).To(BeZero()) - g.Expect(f.HelperCount).To(BeNumerically(">", 0)) - f.ResetHelper() - - testG.Expect("foo").To(Equal("bar")) - g.Expect(f.LastFatal).To(ContainSubstring(": foo")) - g.Expect(f.LastFatal).NotTo(ContainSubstring("testingtsupport_test"), "It should _not_ include a stacktrace") - g.Expect(f.HelperCount).To(BeNumerically(">", 0)) - f.ResetHelper() - - testG.Eventually("foo2", time.Millisecond).Should(Equal("bar")) - g.Expect(f.LastFatal).To(ContainSubstring(": foo2")) - g.Expect(f.HelperCount).To(BeNumerically(">", 0)) - f.ResetHelper() - - testG.Consistently("foo3", time.Millisecond).Should(Equal("bar")) - g.Expect(f.LastFatal).To(ContainSubstring(": foo3")) - g.Expect(f.HelperCount).To(BeNumerically(">", 0)) -} diff --git a/vendor/github.com/onsi/gomega/matchers/and_test.go b/vendor/github.com/onsi/gomega/matchers/and_test.go deleted file mode 100644 index acf778cd6d..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/and_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" - "github.com/onsi/gomega/types" -) - -// sample data -var ( - // example input - input = "hi" - // some matchers that succeed against the input - true1 = HaveLen(2) - true2 = Equal("hi") - true3 = MatchRegexp("hi") - // some matchers that fail against the input. - false1 = HaveLen(1) - false2 = Equal("hip") - false3 = MatchRegexp("hope") -) - -// verifyFailureMessage expects the matcher to fail with the given input, and verifies the failure message. -func verifyFailureMessage(m types.GomegaMatcher, input string, expectedFailureMsgFragment string) { - Expect(m.Match(input)).To(BeFalse()) - Expect(m.FailureMessage(input)).To(Equal( - "Expected\n : " + input + "\n" + expectedFailureMsgFragment)) -} - -var _ = Describe("AndMatcher", func() { - It("works with positive cases", func() { - Expect(input).To(And()) - Expect(input).To(And(true1)) - Expect(input).To(And(true1, true2)) - Expect(input).To(And(true1, true2, true3)) - - // use alias - Expect(input).To(SatisfyAll(true1, true2, true3)) - }) - - It("works with negative cases", func() { - Expect(input).ToNot(And(false1, false2)) - Expect(input).ToNot(And(true1, true2, false3)) - Expect(input).ToNot(And(true1, false2, false3)) - Expect(input).ToNot(And(false1, true1, true2)) - }) - - Context("failure messages", func() { - Context("when match fails", func() { - It("gives a descriptive message", func() { - verifyFailureMessage(And(false1, true1), input, "to have length 1") - verifyFailureMessage(And(true1, false2), input, "to equal\n : hip") - verifyFailureMessage(And(true1, true2, false3), input, "to match regular expression\n : hope") - }) - }) - - Context("when match succeeds, but expected it to fail", func() { - It("gives a descriptive message", func() { - verifyFailureMessage(Not(And(true1, true2)), input, - `To not satisfy all of these matchers: [%!s(*matchers.HaveLenMatcher=&{2}) %!s(*matchers.EqualMatcher=&{hi})]`) - }) - }) - }) - - Context("MatchMayChangeInTheFuture", func() { - Context("Match returned false", func() { - Context("returns value of the failed matcher", func() { - It("false if failed matcher not going to change", func() { - // 3 matchers: 1st returns true, 2nd returns false and is not going to change, 3rd is never called - m := And(Not(BeNil()), Or(), Equal(1)) - Expect(m.Match("hi")).To(BeFalse()) - Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // empty Or() indicates not going to change - }) - It("true if failed matcher indicates it might change", func() { - // 3 matchers: 1st returns true, 2nd returns false and "might" change, 3rd is never called - m := And(Not(BeNil()), Equal(5), Equal(1)) - Expect(m.Match("hi")).To(BeFalse()) - Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // Equal(5) indicates it might change - }) - }) - }) - Context("Match returned true", func() { - It("returns true if any of the matchers could change", func() { - // 3 matchers, all return true, and all could change - m := And(Not(BeNil()), Equal("hi"), HaveLen(2)) - Expect(m.Match("hi")).To(BeTrue()) - Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // all 3 of these matchers default to 'true' - }) - It("returns false if none of the matchers could change", func() { - // empty And() has the property of always matching, and never can change since there are no sub-matchers that could change - m := And() - Expect(m.Match("anything")).To(BeTrue()) - Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse()) - - // And() with 3 sub-matchers that return true, and can't change - m = And(And(), And(), And()) - Expect(m.Match("hi")).To(BeTrue()) - Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // the 3 empty And()'s won't change - }) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go deleted file mode 100644 index 471a46d970..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("AssignableToTypeOf", func() { - Context("When asserting assignability between types", func() { - It("should do the right thing", func() { - Expect(0).Should(BeAssignableToTypeOf(0)) - Expect(5).Should(BeAssignableToTypeOf(-1)) - Expect("foo").Should(BeAssignableToTypeOf("bar")) - Expect(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{})) - - Expect(0).ShouldNot(BeAssignableToTypeOf("bar")) - Expect(5).ShouldNot(BeAssignableToTypeOf(struct{ Foo string }{})) - Expect("foo").ShouldNot(BeAssignableToTypeOf(42)) - }) - }) - - Context("When asserting nil values", func() { - It("should error", func() { - success, err := (&AssignableToTypeOfMatcher{Expected: nil}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - - Context("When actual is nil and expected is not nil", func() { - It("should return false without error", func() { - success, err := (&AssignableToTypeOfMatcher{Expected: 17}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).ShouldNot(HaveOccurred()) - }) - }) - - Context("When actual is not nil and expected is nil", func() { - It("should error", func() { - success, err := (&AssignableToTypeOfMatcher{Expected: nil}).Match(17) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go b/vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go deleted file mode 100644 index bc8742763b..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package matchers_test - -import ( - "io/ioutil" - "os" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeADirectoryMatcher", func() { - Context("when passed a string", func() { - It("should do the right thing", func() { - Expect("/dne/test").ShouldNot(BeADirectory()) - - tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile") - Expect(err).ShouldNot(HaveOccurred()) - defer os.Remove(tmpFile.Name()) - Expect(tmpFile.Name()).ShouldNot(BeADirectory()) - - tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir") - Expect(err).ShouldNot(HaveOccurred()) - defer os.Remove(tmpDir) - Expect(tmpDir).Should(BeADirectory()) - }) - }) - - Context("when passed something else", func() { - It("should error", func() { - success, err := (&BeADirectoryMatcher{}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeADirectoryMatcher{}).Match(true) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go b/vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go deleted file mode 100644 index eae06a03ef..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package matchers_test - -import ( - "io/ioutil" - "os" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeARegularFileMatcher", func() { - Context("when passed a string", func() { - It("should do the right thing", func() { - Expect("/dne/test").ShouldNot(BeARegularFile()) - - tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile") - Expect(err).ShouldNot(HaveOccurred()) - defer os.Remove(tmpFile.Name()) - Expect(tmpFile.Name()).Should(BeARegularFile()) - - tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir") - Expect(err).ShouldNot(HaveOccurred()) - defer os.Remove(tmpDir) - Expect(tmpDir).ShouldNot(BeARegularFile()) - }) - }) - - Context("when passed something else", func() { - It("should error", func() { - success, err := (&BeARegularFileMatcher{}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeARegularFileMatcher{}).Match(true) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go b/vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go deleted file mode 100644 index e28bd0d65b..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package matchers_test - -import ( - "io/ioutil" - "os" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeAnExistingFileMatcher", func() { - Context("when passed a string", func() { - It("should do the right thing", func() { - Expect("/dne/test").ShouldNot(BeAnExistingFile()) - - tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile") - Expect(err).ShouldNot(HaveOccurred()) - defer os.Remove(tmpFile.Name()) - Expect(tmpFile.Name()).Should(BeAnExistingFile()) - - tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir") - Expect(err).ShouldNot(HaveOccurred()) - defer os.Remove(tmpDir) - Expect(tmpDir).Should(BeAnExistingFile()) - }) - }) - - Context("when passed something else", func() { - It("should error", func() { - success, err := (&BeAnExistingFileMatcher{}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeAnExistingFileMatcher{}).Match(true) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go deleted file mode 100644 index c2e49ab508..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeClosedMatcher", func() { - Context("when passed a channel", func() { - It("should do the right thing", func() { - openChannel := make(chan bool) - Expect(openChannel).ShouldNot(BeClosed()) - - var openReaderChannel <-chan bool - openReaderChannel = openChannel - Expect(openReaderChannel).ShouldNot(BeClosed()) - - closedChannel := make(chan bool) - close(closedChannel) - - Expect(closedChannel).Should(BeClosed()) - - var closedReaderChannel <-chan bool - closedReaderChannel = closedChannel - Expect(closedReaderChannel).Should(BeClosed()) - }) - }) - - Context("when passed a send-only channel", func() { - It("should error", func() { - openChannel := make(chan bool) - var openWriterChannel chan<- bool - openWriterChannel = openChannel - - success, err := (&BeClosedMatcher{}).Match(openWriterChannel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - closedChannel := make(chan bool) - close(closedChannel) - - var closedWriterChannel chan<- bool - closedWriterChannel = closedChannel - - success, err = (&BeClosedMatcher{}).Match(closedWriterChannel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - }) - }) - - Context("when passed something else", func() { - It("should error", func() { - var nilChannel chan bool - - success, err := (&BeClosedMatcher{}).Match(nilChannel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeClosedMatcher{}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeClosedMatcher{}).Match(7) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go deleted file mode 100644 index 132480cfc5..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeEmpty", func() { - Context("when passed a supported type", func() { - It("should do the right thing", func() { - Expect("").Should(BeEmpty()) - Expect(" ").ShouldNot(BeEmpty()) - - Expect([0]int{}).Should(BeEmpty()) - Expect([1]int{1}).ShouldNot(BeEmpty()) - - Expect([]int{}).Should(BeEmpty()) - Expect([]int{1}).ShouldNot(BeEmpty()) - - Expect(map[string]int{}).Should(BeEmpty()) - Expect(map[string]int{"a": 1}).ShouldNot(BeEmpty()) - - c := make(chan bool, 1) - Expect(c).Should(BeEmpty()) - c <- true - Expect(c).ShouldNot(BeEmpty()) - }) - }) - - Context("when passed a correctly typed nil", func() { - It("should be true", func() { - var nilSlice []int - Expect(nilSlice).Should(BeEmpty()) - - var nilMap map[int]string - Expect(nilMap).Should(BeEmpty()) - }) - }) - - Context("when passed an unsupported type", func() { - It("should error", func() { - success, err := (&BeEmptyMatcher{}).Match(0) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeEmptyMatcher{}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go deleted file mode 100644 index 4d9d11d2d5..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeEquivalentTo", func() { - Context("when asserting that nil is equivalent to nil", func() { - It("should error", func() { - success, err := (&BeEquivalentToMatcher{Expected: nil}).Match(nil) - - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("When asserting on nil", func() { - It("should do the right thing", func() { - Expect("foo").ShouldNot(BeEquivalentTo(nil)) - Expect(nil).ShouldNot(BeEquivalentTo(3)) - Expect([]int{1, 2}).ShouldNot(BeEquivalentTo(nil)) - }) - }) - - Context("When asserting on type aliases", func() { - It("should the right thing", func() { - Expect(StringAlias("foo")).Should(BeEquivalentTo("foo")) - Expect("foo").Should(BeEquivalentTo(StringAlias("foo"))) - Expect(StringAlias("foo")).ShouldNot(BeEquivalentTo("bar")) - Expect("foo").ShouldNot(BeEquivalentTo(StringAlias("bar"))) - }) - }) - - Context("When asserting on numbers", func() { - It("should convert actual to expected and do the right thing", func() { - Expect(5).Should(BeEquivalentTo(5)) - Expect(5.0).Should(BeEquivalentTo(5.0)) - Expect(5).Should(BeEquivalentTo(5.0)) - - Expect(5).ShouldNot(BeEquivalentTo("5")) - Expect(5).ShouldNot(BeEquivalentTo(3)) - - //Here be dragons! - Expect(5.1).Should(BeEquivalentTo(5)) - Expect(5).ShouldNot(BeEquivalentTo(5.1)) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go deleted file mode 100644 index 25e70633d1..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeFalse", func() { - It("should handle true and false correctly", func() { - Expect(true).ShouldNot(BeFalse()) - Expect(false).Should(BeFalse()) - }) - - It("should only support booleans", func() { - success, err := (&BeFalseMatcher{}).Match("foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go b/vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go deleted file mode 100644 index 7fdd56eedf..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package matchers_test - -import ( - "errors" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeIdenticalTo", func() { - Context("when asserting that nil equals nil", func() { - It("should error", func() { - success, err := (&BeIdenticalToMatcher{Expected: nil}).Match(nil) - - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - It("should treat the same pointer to a struct as identical", func() { - mySpecialStruct := myCustomType{} - Expect(&mySpecialStruct).Should(BeIdenticalTo(&mySpecialStruct)) - Expect(&myCustomType{}).ShouldNot(BeIdenticalTo(&mySpecialStruct)) - }) - - It("should be strict about types", func() { - Expect(5).ShouldNot(BeIdenticalTo("5")) - Expect(5).ShouldNot(BeIdenticalTo(5.0)) - Expect(5).ShouldNot(BeIdenticalTo(3)) - }) - - It("should treat primtives as identical", func() { - Expect("5").Should(BeIdenticalTo("5")) - Expect("5").ShouldNot(BeIdenticalTo("55")) - - Expect(5.55).Should(BeIdenticalTo(5.55)) - Expect(5.55).ShouldNot(BeIdenticalTo(6.66)) - - Expect(5).Should(BeIdenticalTo(5)) - Expect(5).ShouldNot(BeIdenticalTo(55)) - }) - - It("should treat the same pointers to a slice as identical", func() { - mySlice := []int{1, 2} - Expect(&mySlice).Should(BeIdenticalTo(&mySlice)) - Expect(&mySlice).ShouldNot(BeIdenticalTo(&[]int{1, 2})) - }) - - It("should treat the same pointers to a map as identical", func() { - myMap := map[string]string{"a": "b", "c": "d"} - Expect(&myMap).Should(BeIdenticalTo(&myMap)) - Expect(myMap).ShouldNot(BeIdenticalTo(map[string]string{"a": "b", "c": "d"})) - }) - - It("should treat the same pointers to an error as identical", func() { - myError := errors.New("foo") - Expect(&myError).Should(BeIdenticalTo(&myError)) - Expect(errors.New("foo")).ShouldNot(BeIdenticalTo(errors.New("bar"))) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go deleted file mode 100644 index c35aa3d7c7..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("BeNil", func() { - It("should succeed when passed nil", func() { - Expect(nil).Should(BeNil()) - }) - - It("should succeed when passed a typed nil", func() { - var a []int - Expect(a).Should(BeNil()) - }) - - It("should succeed when passing nil pointer", func() { - var f *struct{} - Expect(f).Should(BeNil()) - }) - - It("should not succeed when not passed nil", func() { - Expect(0).ShouldNot(BeNil()) - Expect(false).ShouldNot(BeNil()) - Expect("").ShouldNot(BeNil()) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go deleted file mode 100644 index a32d2b8b17..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go +++ /dev/null @@ -1,172 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeNumerically", func() { - Context("when passed a number", func() { - It("should support ==", func() { - Expect(uint32(5)).Should(BeNumerically("==", 5)) - Expect(float64(5.0)).Should(BeNumerically("==", 5)) - Expect(int8(5)).Should(BeNumerically("==", 5)) - }) - - It("should not have false positives", func() { - Expect(5.1).ShouldNot(BeNumerically("==", 5)) - Expect(5).ShouldNot(BeNumerically("==", 5.1)) - }) - - It("should support >", func() { - Expect(uint32(5)).Should(BeNumerically(">", 4)) - Expect(float64(5.0)).Should(BeNumerically(">", 4.9)) - Expect(int8(5)).Should(BeNumerically(">", 4)) - - Expect(uint32(5)).ShouldNot(BeNumerically(">", 5)) - Expect(float64(5.0)).ShouldNot(BeNumerically(">", 5.0)) - Expect(int8(5)).ShouldNot(BeNumerically(">", 5)) - }) - - It("should support <", func() { - Expect(uint32(5)).Should(BeNumerically("<", 6)) - Expect(float64(5.0)).Should(BeNumerically("<", 5.1)) - Expect(int8(5)).Should(BeNumerically("<", 6)) - - Expect(uint32(5)).ShouldNot(BeNumerically("<", 5)) - Expect(float64(5.0)).ShouldNot(BeNumerically("<", 5.0)) - Expect(int8(5)).ShouldNot(BeNumerically("<", 5)) - }) - - It("should support >=", func() { - Expect(uint32(5)).Should(BeNumerically(">=", 4)) - Expect(float64(5.0)).Should(BeNumerically(">=", 4.9)) - Expect(int8(5)).Should(BeNumerically(">=", 4)) - - Expect(uint32(5)).Should(BeNumerically(">=", 5)) - Expect(float64(5.0)).Should(BeNumerically(">=", 5.0)) - Expect(int8(5)).Should(BeNumerically(">=", 5)) - - Expect(uint32(5)).ShouldNot(BeNumerically(">=", 6)) - Expect(float64(5.0)).ShouldNot(BeNumerically(">=", 5.1)) - Expect(int8(5)).ShouldNot(BeNumerically(">=", 6)) - }) - - It("should support <=", func() { - Expect(uint32(5)).Should(BeNumerically("<=", 6)) - Expect(float64(5.0)).Should(BeNumerically("<=", 5.1)) - Expect(int8(5)).Should(BeNumerically("<=", 6)) - - Expect(uint32(5)).Should(BeNumerically("<=", 5)) - Expect(float64(5.0)).Should(BeNumerically("<=", 5.0)) - Expect(int8(5)).Should(BeNumerically("<=", 5)) - - Expect(uint32(5)).ShouldNot(BeNumerically("<=", 4)) - Expect(float64(5.0)).ShouldNot(BeNumerically("<=", 4.9)) - Expect(int8(5)).Should(BeNumerically("<=", 5)) - }) - - Context("when passed ~", func() { - Context("when passed a float", func() { - Context("and there is no precision parameter", func() { - It("should default to 1e-8", func() { - Expect(5.00000001).Should(BeNumerically("~", 5.00000002)) - Expect(5.00000001).ShouldNot(BeNumerically("~", 5.0000001)) - }) - - It("should show failure message", func() { - actual := BeNumerically("~", 4.98).FailureMessage(123) - expected := "Expected\n : 123\nto be ~\n : 4.98" - Expect(actual).To(Equal(expected)) - }) - - It("should show negated failure message", func() { - actual := BeNumerically("~", 4.98).NegatedFailureMessage(123) - expected := "Expected\n : 123\nnot to be ~\n : 4.98" - Expect(actual).To(Equal(expected)) - }) - }) - - Context("and there is a precision parameter", func() { - It("should use the precision parameter", func() { - Expect(5.1).Should(BeNumerically("~", 5.19, 0.1)) - Expect(5.1).Should(BeNumerically("~", 5.01, 0.1)) - Expect(5.1).ShouldNot(BeNumerically("~", 5.22, 0.1)) - Expect(5.1).ShouldNot(BeNumerically("~", 4.98, 0.1)) - }) - - It("should show precision in failure message", func() { - actual := BeNumerically("~", 4.98, 0.1).FailureMessage(123) - expected := "Expected\n : 123\nto be within 0.1 of ~\n : 4.98" - Expect(actual).To(Equal(expected)) - }) - - It("should show precision in negated failure message", func() { - actual := BeNumerically("~", 4.98, 0.1).NegatedFailureMessage(123) - expected := "Expected\n : 123\nnot to be within 0.1 of ~\n : 4.98" - Expect(actual).To(Equal(expected)) - }) - }) - }) - - Context("when passed an int/uint", func() { - Context("and there is no precision parameter", func() { - It("should just do strict equality", func() { - Expect(5).Should(BeNumerically("~", 5)) - Expect(5).ShouldNot(BeNumerically("~", 6)) - Expect(uint(5)).ShouldNot(BeNumerically("~", 6)) - }) - }) - - Context("and there is a precision parameter", func() { - It("should use precision paramter", func() { - Expect(5).Should(BeNumerically("~", 6, 2)) - Expect(5).ShouldNot(BeNumerically("~", 8, 2)) - Expect(uint(5)).Should(BeNumerically("~", 6, 1)) - }) - }) - }) - }) - }) - - Context("when passed a non-number", func() { - It("should error", func() { - success, err := (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{5}}).Match("foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeNumericallyMatcher{Comparator: "=="}).Match(5) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeNumericallyMatcher{Comparator: "~", CompareTo: []interface{}{3.0, "foo"}}).Match(5.0) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{"bar"}}).Match(5) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{"bar"}}).Match("foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{nil}}).Match(0) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{0}}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed an unsupported comparator", func() { - It("should error", func() { - success, err := (&BeNumericallyMatcher{Comparator: "!=", CompareTo: []interface{}{5}}).Match(4) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go deleted file mode 100644 index 68ec72879d..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package matchers_test - -import ( - "time" - - . "github.com/onsi/gomega/matchers" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("BeSent", func() { - Context("when passed a channel and a matching type", func() { - Context("when the channel is ready to receive", func() { - It("should succeed and send the value down the channel", func() { - c := make(chan string) - d := make(chan string) - go func() { - val := <-c - d <- val - }() - - time.Sleep(10 * time.Millisecond) - - Expect(c).Should(BeSent("foo")) - Eventually(d).Should(Receive(Equal("foo"))) - }) - - It("should succeed (with a buffered channel)", func() { - c := make(chan string, 1) - Expect(c).Should(BeSent("foo")) - Expect(<-c).Should(Equal("foo")) - }) - }) - - Context("when the channel is not ready to receive", func() { - It("should fail and not send down the channel", func() { - c := make(chan string) - Expect(c).ShouldNot(BeSent("foo")) - Consistently(c).ShouldNot(Receive()) - }) - }) - - Context("when the channel is eventually ready to receive", func() { - It("should succeed", func() { - c := make(chan string) - d := make(chan string) - go func() { - time.Sleep(30 * time.Millisecond) - val := <-c - d <- val - }() - - Eventually(c).Should(BeSent("foo")) - Eventually(d).Should(Receive(Equal("foo"))) - }) - }) - - Context("when the channel is closed", func() { - It("should error", func() { - c := make(chan string) - close(c) - success, err := (&BeSentMatcher{Arg: "foo"}).Match(c) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - - It("should short-circuit Eventually", func() { - c := make(chan string) - close(c) - - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(c, 10.0).Should(BeSent("foo")) - }) - Expect(failures).Should(HaveLen(1)) - Expect(time.Since(t)).Should(BeNumerically("<", time.Second)) - }) - }) - }) - - Context("when passed a channel and a non-matching type", func() { - It("should error", func() { - success, err := (&BeSentMatcher{Arg: "foo"}).Match(make(chan int, 1)) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed a receive-only channel", func() { - It("should error", func() { - var c <-chan string - c = make(chan string, 1) - success, err := (&BeSentMatcher{Arg: "foo"}).Match(c) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed a nonchannel", func() { - It("should error", func() { - success, err := (&BeSentMatcher{Arg: "foo"}).Match("bar") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go deleted file mode 100644 index 95a3a103e0..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package matchers_test - -import ( - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeTemporally", func() { - - var t0, t1, t2 time.Time - BeforeEach(func() { - t0 = time.Now() - t1 = t0.Add(time.Second) - t2 = t0.Add(-time.Second) - }) - - Context("When comparing times", func() { - - It("should support ==", func() { - Expect(t0).Should(BeTemporally("==", t0)) - Expect(t1).ShouldNot(BeTemporally("==", t0)) - Expect(t0).ShouldNot(BeTemporally("==", t1)) - Expect(t0).ShouldNot(BeTemporally("==", time.Time{})) - }) - - It("should support >", func() { - Expect(t0).Should(BeTemporally(">", t2)) - Expect(t0).ShouldNot(BeTemporally(">", t0)) - Expect(t2).ShouldNot(BeTemporally(">", t0)) - }) - - It("should support <", func() { - Expect(t0).Should(BeTemporally("<", t1)) - Expect(t0).ShouldNot(BeTemporally("<", t0)) - Expect(t1).ShouldNot(BeTemporally("<", t0)) - }) - - It("should support >=", func() { - Expect(t0).Should(BeTemporally(">=", t2)) - Expect(t0).Should(BeTemporally(">=", t0)) - Expect(t0).ShouldNot(BeTemporally(">=", t1)) - }) - - It("should support <=", func() { - Expect(t0).Should(BeTemporally("<=", t1)) - Expect(t0).Should(BeTemporally("<=", t0)) - Expect(t0).ShouldNot(BeTemporally("<=", t2)) - }) - - Context("when passed ~", func() { - Context("and there is no precision parameter", func() { - BeforeEach(func() { - t1 = t0.Add(time.Millisecond / 2) - t2 = t0.Add(-2 * time.Millisecond) - }) - It("should approximate", func() { - Expect(t0).Should(BeTemporally("~", t0)) - Expect(t0).Should(BeTemporally("~", t1)) - Expect(t0).ShouldNot(BeTemporally("~", t2)) - }) - }) - - Context("and there is a precision parameter", func() { - BeforeEach(func() { - t2 = t0.Add(3 * time.Second) - }) - It("should use precision paramter", func() { - d := 2 * time.Second - Expect(t0).Should(BeTemporally("~", t0, d)) - Expect(t0).Should(BeTemporally("~", t1, d)) - Expect(t0).ShouldNot(BeTemporally("~", t2, d)) - }) - }) - }) - }) - - Context("when passed a non-time", func() { - It("should error", func() { - success, err := (&BeTemporallyMatcher{Comparator: "==", CompareTo: t0}).Match("foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&BeTemporallyMatcher{Comparator: "=="}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed an unsupported comparator", func() { - It("should error", func() { - success, err := (&BeTemporallyMatcher{Comparator: "!=", CompareTo: t0}).Match(t2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go deleted file mode 100644 index 9eda62c33e..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("BeTrue", func() { - It("should handle true and false correctly", func() { - Expect(true).Should(BeTrue()) - Expect(false).ShouldNot(BeTrue()) - }) - - It("should only support booleans", func() { - success, err := (&BeTrueMatcher{}).Match("foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go deleted file mode 100644 index c89e103302..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("BeZero", func() { - It("succeeds for zero values for its type", func() { - Expect(nil).Should(BeZero()) - - Expect("").Should(BeZero()) - Expect(" ").ShouldNot(BeZero()) - - Expect(0).Should(BeZero()) - Expect(1).ShouldNot(BeZero()) - - Expect(0.0).Should(BeZero()) - Expect(0.1).ShouldNot(BeZero()) - - // Expect([]int{}).Should(BeZero()) - Expect([]int{1}).ShouldNot(BeZero()) - - // Expect(map[string]int{}).Should(BeZero()) - Expect(map[string]int{"a": 1}).ShouldNot(BeZero()) - - Expect(myCustomType{}).Should(BeZero()) - Expect(myCustomType{s: "a"}).ShouldNot(BeZero()) - }) - - It("builds failure message", func() { - actual := BeZero().FailureMessage(123) - Expect(actual).To(Equal("Expected\n : 123\nto be zero-valued")) - }) - - It("builds negated failure message", func() { - actual := BeZero().NegatedFailureMessage(123) - Expect(actual).To(Equal("Expected\n : 123\nnot to be zero-valued")) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/consist_of_test.go b/vendor/github.com/onsi/gomega/matchers/consist_of_test.go deleted file mode 100644 index f6971c4f55..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/consist_of_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("ConsistOf", func() { - Context("with a slice", func() { - It("should do the right thing", func() { - Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", "bar", "baz")) - Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", "bar", "baz")) - Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("baz", "bar", "foo")) - Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "bar", "foo", "foo")) - Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "foo")) - }) - }) - - Context("with an array", func() { - It("should do the right thing", func() { - Expect([3]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", "bar", "baz")) - Expect([3]string{"foo", "bar", "baz"}).Should(ConsistOf("baz", "bar", "foo")) - Expect([3]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "bar", "foo", "foo")) - Expect([3]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "foo")) - }) - }) - - Context("with a map", func() { - It("should apply to the values", func() { - Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).Should(ConsistOf("foo", "bar", "baz")) - Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).Should(ConsistOf("baz", "bar", "foo")) - Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).ShouldNot(ConsistOf("baz", "bar", "foo", "foo")) - Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).ShouldNot(ConsistOf("baz", "foo")) - }) - - }) - - Context("with anything else", func() { - It("should error", func() { - failures := InterceptGomegaFailures(func() { - Expect("foo").Should(ConsistOf("f", "o", "o")) - }) - - Expect(failures).Should(HaveLen(1)) - }) - }) - - Context("when passed matchers", func() { - It("should pass if the matchers pass", func() { - Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", MatchRegexp("^ba"), "baz")) - Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("foo", MatchRegexp("^ba"))) - Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("foo", MatchRegexp("^ba"), MatchRegexp("foo"))) - Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", MatchRegexp("^ba"), MatchRegexp("^ba"))) - Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("foo", MatchRegexp("^ba"), MatchRegexp("turducken"))) - }) - - It("should not depend on the order of the matchers", func() { - Expect([][]int{{1, 2}, {2}}).Should(ConsistOf(ContainElement(1), ContainElement(2))) - Expect([][]int{{1, 2}, {2}}).Should(ConsistOf(ContainElement(2), ContainElement(1))) - }) - - Context("when a matcher errors", func() { - It("should soldier on", func() { - Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf(BeFalse(), "foo", "bar")) - Expect([]interface{}{"foo", "bar", false}).Should(ConsistOf(BeFalse(), ContainSubstring("foo"), "bar")) - }) - }) - }) - - Context("when passed exactly one argument, and that argument is a slice", func() { - It("should match against the elements of that argument", func() { - Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf([]string{"foo", "bar", "baz"})) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go deleted file mode 100644 index 60fb55e963..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("ContainElement", func() { - Context("when passed a supported type", func() { - Context("and expecting a non-matcher", func() { - It("should do the right thing", func() { - Expect([2]int{1, 2}).Should(ContainElement(2)) - Expect([2]int{1, 2}).ShouldNot(ContainElement(3)) - - Expect([]int{1, 2}).Should(ContainElement(2)) - Expect([]int{1, 2}).ShouldNot(ContainElement(3)) - - Expect(map[string]int{"foo": 1, "bar": 2}).Should(ContainElement(2)) - Expect(map[int]int{3: 1, 4: 2}).ShouldNot(ContainElement(3)) - - arr := make([]myCustomType, 2) - arr[0] = myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}} - arr[1] = myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "c"}} - Expect(arr).Should(ContainElement(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}})) - Expect(arr).ShouldNot(ContainElement(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"b", "c"}})) - }) - }) - - Context("and expecting a matcher", func() { - It("should pass each element through the matcher", func() { - Expect([]int{1, 2, 3}).Should(ContainElement(BeNumerically(">=", 3))) - Expect([]int{1, 2, 3}).ShouldNot(ContainElement(BeNumerically(">", 3))) - Expect(map[string]int{"foo": 1, "bar": 2}).Should(ContainElement(BeNumerically(">=", 2))) - Expect(map[string]int{"foo": 1, "bar": 2}).ShouldNot(ContainElement(BeNumerically(">", 2))) - }) - - It("should power through even if the matcher ever fails", func() { - Expect([]interface{}{1, 2, "3", 4}).Should(ContainElement(BeNumerically(">=", 3))) - }) - - It("should fail if the matcher fails", func() { - actual := []interface{}{1, 2, "3", "4"} - success, err := (&ContainElementMatcher{Element: BeNumerically(">=", 3)}).Match(actual) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - }) - - Context("when passed a correctly typed nil", func() { - It("should operate succesfully on the passed in value", func() { - var nilSlice []int - Expect(nilSlice).ShouldNot(ContainElement(1)) - - var nilMap map[int]string - Expect(nilMap).ShouldNot(ContainElement("foo")) - }) - }) - - Context("when passed an unsupported type", func() { - It("should error", func() { - success, err := (&ContainElementMatcher{Element: 0}).Match(0) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&ContainElementMatcher{Element: 0}).Match("abc") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&ContainElementMatcher{Element: 0}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go deleted file mode 100644 index efffb47325..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("ContainSubstringMatcher", func() { - Context("when actual is a string", func() { - It("should match against the string", func() { - Expect("Marvelous").Should(ContainSubstring("rve")) - Expect("Marvelous").ShouldNot(ContainSubstring("boo")) - }) - }) - - Context("when the matcher is called with multiple arguments", func() { - It("should pass the string and arguments to sprintf", func() { - Expect("Marvelous3").Should(ContainSubstring("velous%d", 3)) - }) - }) - - Context("when actual is a stringer", func() { - It("should call the stringer and match agains the returned string", func() { - Expect(&myStringer{a: "Abc3"}).Should(ContainSubstring("bc3")) - }) - }) - - Context("when actual is neither a string nor a stringer", func() { - It("should error", func() { - success, err := (&ContainSubstringMatcher{Substr: "2"}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go deleted file mode 100644 index 3ab991e4fa..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go +++ /dev/null @@ -1,80 +0,0 @@ -package matchers_test - -import ( - "errors" - "strings" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("Equal", func() { - Context("when asserting that nil equals nil", func() { - It("should error", func() { - success, err := (&EqualMatcher{Expected: nil}).Match(nil) - - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("When asserting equality between objects", func() { - It("should do the right thing", func() { - Expect(5).Should(Equal(5)) - Expect(5.0).Should(Equal(5.0)) - - Expect(5).ShouldNot(Equal("5")) - Expect(5).ShouldNot(Equal(5.0)) - Expect(5).ShouldNot(Equal(3)) - - Expect("5").Should(Equal("5")) - Expect([]int{1, 2}).Should(Equal([]int{1, 2})) - Expect([]int{1, 2}).ShouldNot(Equal([]int{2, 1})) - Expect([]byte{'f', 'o', 'o'}).Should(Equal([]byte{'f', 'o', 'o'})) - Expect([]byte{'f', 'o', 'o'}).ShouldNot(Equal([]byte{'b', 'a', 'r'})) - Expect(map[string]string{"a": "b", "c": "d"}).Should(Equal(map[string]string{"a": "b", "c": "d"})) - Expect(map[string]string{"a": "b", "c": "d"}).ShouldNot(Equal(map[string]string{"a": "b", "c": "e"})) - Expect(errors.New("foo")).Should(Equal(errors.New("foo"))) - Expect(errors.New("foo")).ShouldNot(Equal(errors.New("bar"))) - - Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).Should(Equal(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}})) - Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "bar", n: 3, f: 2.0, arr: []string{"a", "b"}})) - Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 2, f: 2.0, arr: []string{"a", "b"}})) - Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 3, f: 3.0, arr: []string{"a", "b"}})) - Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b", "c"}})) - }) - }) - - Describe("failure messages", func() { - It("shows the two strings simply when they are short", func() { - subject := EqualMatcher{Expected: "eric"} - - failureMessage := subject.FailureMessage("tim") - Expect(failureMessage).To(BeEquivalentTo(expectedShortStringFailureMessage)) - }) - - It("shows the exact point where two long strings differ", func() { - stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - - subject := EqualMatcher{Expected: stringWithZ} - - failureMessage := subject.FailureMessage(stringWithB) - Expect(failureMessage).To(BeEquivalentTo(expectedLongStringFailureMessage)) - }) - }) -}) - -var expectedShortStringFailureMessage = strings.TrimSpace(` -Expected - : tim -to equal - : eric -`) -var expectedLongStringFailureMessage = strings.TrimSpace(` -Expected - : "...aaaaabaaaaa..." -to equal | - : "...aaaaazaaaaa..." -`) diff --git a/vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go deleted file mode 100644 index 8a61f2e2c5..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("HaveCap", func() { - Context("when passed a supported type", func() { - It("should do the right thing", func() { - Expect([0]int{}).Should(HaveCap(0)) - Expect([2]int{1}).Should(HaveCap(2)) - - Expect([]int{}).Should(HaveCap(0)) - Expect([]int{1, 2, 3, 4, 5}[:2]).Should(HaveCap(5)) - Expect(make([]int, 0, 5)).Should(HaveCap(5)) - - c := make(chan bool, 3) - Expect(c).Should(HaveCap(3)) - c <- true - c <- true - Expect(c).Should(HaveCap(3)) - - Expect(make(chan bool)).Should(HaveCap(0)) - }) - }) - - Context("when passed a correctly typed nil", func() { - It("should operate succesfully on the passed in value", func() { - var nilSlice []int - Expect(nilSlice).Should(HaveCap(0)) - - var nilChan chan int - Expect(nilChan).Should(HaveCap(0)) - }) - }) - - Context("when passed an unsupported type", func() { - It("should error", func() { - success, err := (&HaveCapMatcher{Count: 0}).Match(0) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&HaveCapMatcher{Count: 0}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go deleted file mode 100644 index 0f1561b7de..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("HaveKey", func() { - var ( - stringKeys map[string]int - intKeys map[int]string - objKeys map[*myCustomType]string - - customA *myCustomType - customB *myCustomType - ) - BeforeEach(func() { - stringKeys = map[string]int{"foo": 2, "bar": 3} - intKeys = map[int]string{2: "foo", 3: "bar"} - - customA = &myCustomType{s: "a", n: 2, f: 2.3, arr: []string{"ice", "cream"}} - customB = &myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}} - objKeys = map[*myCustomType]string{customA: "aardvark", customB: "kangaroo"} - }) - - Context("when passed a map", func() { - It("should do the right thing", func() { - Expect(stringKeys).Should(HaveKey("foo")) - Expect(stringKeys).ShouldNot(HaveKey("baz")) - - Expect(intKeys).Should(HaveKey(2)) - Expect(intKeys).ShouldNot(HaveKey(4)) - - Expect(objKeys).Should(HaveKey(customA)) - Expect(objKeys).Should(HaveKey(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}})) - Expect(objKeys).ShouldNot(HaveKey(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"apple", "pie"}})) - }) - }) - - Context("when passed a correctly typed nil", func() { - It("should operate succesfully on the passed in value", func() { - var nilMap map[int]string - Expect(nilMap).ShouldNot(HaveKey("foo")) - }) - }) - - Context("when the passed in key is actually a matcher", func() { - It("should pass each element through the matcher", func() { - Expect(stringKeys).Should(HaveKey(ContainSubstring("oo"))) - Expect(stringKeys).ShouldNot(HaveKey(ContainSubstring("foobar"))) - }) - - It("should fail if the matcher ever fails", func() { - actual := map[int]string{1: "a", 3: "b", 2: "c"} - success, err := (&HaveKeyMatcher{Key: ContainSubstring("ar")}).Match(actual) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed something that is not a map", func() { - It("should error", func() { - success, err := (&HaveKeyMatcher{Key: "foo"}).Match([]string{"foo"}) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&HaveKeyMatcher{Key: "foo"}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go deleted file mode 100644 index 0a49ec9935..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("HaveKeyWithValue", func() { - var ( - stringKeys map[string]int - intKeys map[int]string - objKeys map[*myCustomType]*myCustomType - - customA *myCustomType - customB *myCustomType - ) - BeforeEach(func() { - stringKeys = map[string]int{"foo": 2, "bar": 3} - intKeys = map[int]string{2: "foo", 3: "bar"} - - customA = &myCustomType{s: "a", n: 2, f: 2.3, arr: []string{"ice", "cream"}} - customB = &myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}} - objKeys = map[*myCustomType]*myCustomType{customA: customA, customB: customA} - }) - - Context("when passed a map", func() { - It("should do the right thing", func() { - Expect(stringKeys).Should(HaveKeyWithValue("foo", 2)) - Expect(stringKeys).ShouldNot(HaveKeyWithValue("foo", 1)) - Expect(stringKeys).ShouldNot(HaveKeyWithValue("baz", 2)) - Expect(stringKeys).ShouldNot(HaveKeyWithValue("baz", 1)) - - Expect(intKeys).Should(HaveKeyWithValue(2, "foo")) - Expect(intKeys).ShouldNot(HaveKeyWithValue(4, "foo")) - Expect(intKeys).ShouldNot(HaveKeyWithValue(2, "baz")) - - Expect(objKeys).Should(HaveKeyWithValue(customA, customA)) - Expect(objKeys).Should(HaveKeyWithValue(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}}, &myCustomType{s: "a", n: 2, f: 2.3, arr: []string{"ice", "cream"}})) - Expect(objKeys).ShouldNot(HaveKeyWithValue(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"apple", "pie"}}, customA)) - }) - }) - - Context("when passed a correctly typed nil", func() { - It("should operate succesfully on the passed in value", func() { - var nilMap map[int]string - Expect(nilMap).ShouldNot(HaveKeyWithValue("foo", "bar")) - }) - }) - - Context("when the passed in key or value is actually a matcher", func() { - It("should pass each element through the matcher", func() { - Expect(stringKeys).Should(HaveKeyWithValue(ContainSubstring("oo"), 2)) - Expect(intKeys).Should(HaveKeyWithValue(2, ContainSubstring("oo"))) - Expect(stringKeys).ShouldNot(HaveKeyWithValue(ContainSubstring("foobar"), 2)) - }) - - It("should fail if the matcher ever fails", func() { - actual := map[int]string{1: "a", 3: "b", 2: "c"} - success, err := (&HaveKeyWithValueMatcher{Key: ContainSubstring("ar"), Value: 2}).Match(actual) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - otherActual := map[string]int{"a": 1, "b": 2, "c": 3} - success, err = (&HaveKeyWithValueMatcher{Key: "a", Value: ContainSubstring("1")}).Match(otherActual) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed something that is not a map", func() { - It("should error", func() { - success, err := (&HaveKeyWithValueMatcher{Key: "foo", Value: "bar"}).Match([]string{"foo"}) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&HaveKeyWithValueMatcher{Key: "foo", Value: "bar"}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go deleted file mode 100644 index c60f638865..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("HaveLen", func() { - Context("when passed a supported type", func() { - It("should do the right thing", func() { - Expect("").Should(HaveLen(0)) - Expect("AA").Should(HaveLen(2)) - - Expect([0]int{}).Should(HaveLen(0)) - Expect([2]int{1, 2}).Should(HaveLen(2)) - - Expect([]int{}).Should(HaveLen(0)) - Expect([]int{1, 2, 3}).Should(HaveLen(3)) - - Expect(map[string]int{}).Should(HaveLen(0)) - Expect(map[string]int{"a": 1, "b": 2, "c": 3, "d": 4}).Should(HaveLen(4)) - - c := make(chan bool, 3) - Expect(c).Should(HaveLen(0)) - c <- true - c <- true - Expect(c).Should(HaveLen(2)) - }) - }) - - Context("when passed a correctly typed nil", func() { - It("should operate succesfully on the passed in value", func() { - var nilSlice []int - Expect(nilSlice).Should(HaveLen(0)) - - var nilMap map[int]string - Expect(nilMap).Should(HaveLen(0)) - }) - }) - - Context("when passed an unsupported type", func() { - It("should error", func() { - success, err := (&HaveLenMatcher{Count: 0}).Match(0) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&HaveLenMatcher{Count: 0}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go deleted file mode 100644 index 0ad632ec1a..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package matchers_test - -import ( - "errors" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -type CustomErr struct { - msg string -} - -func (e *CustomErr) Error() string { - return e.msg -} - -var _ = Describe("HaveOccurred", func() { - It("should succeed if matching an error", func() { - Expect(errors.New("Foo")).Should(HaveOccurred()) - }) - - It("should not succeed with nil", func() { - Expect(nil).ShouldNot(HaveOccurred()) - }) - - It("should only support errors and nil", func() { - success, err := (&HaveOccurredMatcher{}).Match("foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&HaveOccurredMatcher{}).Match("") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - - It("doesn't support non-error type", func() { - success, err := (&HaveOccurredMatcher{}).Match(AnyType{}) - Expect(success).Should(BeFalse()) - Expect(err).Should(MatchError("Expected an error-type. Got:\n : {}")) - }) - - It("doesn't support non-error pointer type", func() { - success, err := (&HaveOccurredMatcher{}).Match(&AnyType{}) - Expect(success).Should(BeFalse()) - Expect(err).Should(MatchError(MatchRegexp(`Expected an error-type. Got:\n <*matchers_test.AnyType | 0x[[:xdigit:]]+>: {}`))) - }) - - It("should succeed with pointer types that conform to error interface", func() { - err := &CustomErr{"ohai"} - Expect(err).Should(HaveOccurred()) - }) - - It("should not succeed with nil pointers to types that conform to error interface", func() { - var err *CustomErr = nil - Expect(err).ShouldNot(HaveOccurred()) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go deleted file mode 100644 index fe29b7b5dc..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("HavePrefixMatcher", func() { - Context("when actual is a string", func() { - It("should match a string prefix", func() { - Expect("Ab").Should(HavePrefix("A")) - Expect("A").ShouldNot(HavePrefix("Ab")) - }) - }) - - Context("when the matcher is called with multiple arguments", func() { - It("should pass the string and arguments to sprintf", func() { - Expect("C3PO").Should(HavePrefix("C%dP", 3)) - }) - }) - - Context("when actual is a stringer", func() { - It("should call the stringer and match against the returned string", func() { - Expect(&myStringer{a: "Ab"}).Should(HavePrefix("A")) - }) - }) - - Context("when actual is neither a string nor a stringer", func() { - It("should error", func() { - success, err := (&HavePrefixMatcher{Prefix: "2"}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go deleted file mode 100644 index 2ae29821a5..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("HaveSuffixMatcher", func() { - Context("when actual is a string", func() { - It("should match a string suffix", func() { - Expect("Ab").Should(HaveSuffix("b")) - Expect("A").ShouldNot(HaveSuffix("Ab")) - }) - }) - - Context("when the matcher is called with multiple arguments", func() { - It("should pass the string and arguments to sprintf", func() { - Expect("C3PO").Should(HaveSuffix("%dPO", 3)) - }) - }) - - Context("when actual is a stringer", func() { - It("should call the stringer and match against the returned string", func() { - Expect(&myStringer{a: "Ab"}).Should(HaveSuffix("b")) - }) - }) - - Context("when actual is neither a string nor a stringer", func() { - It("should error", func() { - success, err := (&HaveSuffixMatcher{Suffix: "2"}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go deleted file mode 100644 index 9bf89fc467..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package matchers_test - -import ( - "errors" - "fmt" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -type CustomError struct { -} - -func (c CustomError) Error() string { - return "an error" -} - -var _ = Describe("MatchErrorMatcher", func() { - Context("When asserting against an error", func() { - It("should succeed when matching with an error", func() { - err := errors.New("an error") - fmtErr := fmt.Errorf("an error") - customErr := CustomError{} - - Expect(err).Should(MatchError(errors.New("an error"))) - Expect(err).ShouldNot(MatchError(errors.New("another error"))) - - Expect(fmtErr).Should(MatchError(errors.New("an error"))) - Expect(customErr).Should(MatchError(CustomError{})) - }) - - It("should succeed when matching with a string", func() { - err := errors.New("an error") - fmtErr := fmt.Errorf("an error") - customErr := CustomError{} - - Expect(err).Should(MatchError("an error")) - Expect(err).ShouldNot(MatchError("another error")) - - Expect(fmtErr).Should(MatchError("an error")) - Expect(customErr).Should(MatchError("an error")) - }) - - Context("when passed a matcher", func() { - It("should pass if the matcher passes against the error string", func() { - err := errors.New("error 123 abc") - - Expect(err).Should(MatchError(MatchRegexp(`\d{3}`))) - }) - - It("should fail if the matcher fails against the error string", func() { - err := errors.New("no digits") - Expect(err).ShouldNot(MatchError(MatchRegexp(`\d`))) - }) - }) - - It("should fail when passed anything else", func() { - actualErr := errors.New("an error") - _, err := (&MatchErrorMatcher{ - Expected: []byte("an error"), - }).Match(actualErr) - Expect(err).Should(HaveOccurred()) - - _, err = (&MatchErrorMatcher{ - Expected: 3, - }).Match(actualErr) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed nil", func() { - It("should fail", func() { - _, err := (&MatchErrorMatcher{ - Expected: "an error", - }).Match(nil) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed a non-error", func() { - It("should fail", func() { - _, err := (&MatchErrorMatcher{ - Expected: "an error", - }).Match("an error") - Expect(err).Should(HaveOccurred()) - - _, err = (&MatchErrorMatcher{ - Expected: "an error", - }).Match(3) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when passed an error that is also a string", func() { - It("should use it as an error", func() { - var e mockErr = "mockErr" - - // this fails if the matcher casts e to a string before comparison - Expect(e).Should(MatchError(e)) - }) - }) -}) - -type mockErr string - -func (m mockErr) Error() string { return string(m) } diff --git a/vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go deleted file mode 100644 index 4a1a9db204..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package matchers_test - -import ( - "encoding/json" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("MatchJSONMatcher", func() { - Context("When passed stringifiables", func() { - It("should succeed if the JSON matches", func() { - Expect("{}").Should(MatchJSON("{}")) - Expect(`{"a":1}`).Should(MatchJSON(`{"a":1}`)) - Expect(`{ - "a":1 - }`).Should(MatchJSON(`{"a":1}`)) - Expect(`{"a":1, "b":2}`).Should(MatchJSON(`{"b":2, "a":1}`)) - Expect(`{"a":1}`).ShouldNot(MatchJSON(`{"b":2, "a":1}`)) - - Expect(`{"a":"a", "b":"b"}`).ShouldNot(MatchJSON(`{"a":"a", "b":"b", "c":"c"}`)) - Expect(`{"a":"a", "b":"b", "c":"c"}`).ShouldNot(MatchJSON(`{"a":"a", "b":"b"}`)) - - Expect(`{"a":null, "b":null}`).ShouldNot(MatchJSON(`{"c":"c", "d":"d"}`)) - Expect(`{"a":null, "b":null, "c":null}`).ShouldNot(MatchJSON(`{"a":null, "b":null, "d":null}`)) - }) - - It("should work with byte arrays", func() { - Expect([]byte("{}")).Should(MatchJSON([]byte("{}"))) - Expect("{}").Should(MatchJSON([]byte("{}"))) - Expect([]byte("{}")).Should(MatchJSON("{}")) - }) - - It("should work with json.RawMessage", func() { - Expect([]byte(`{"a": 1}`)).Should(MatchJSON(json.RawMessage(`{"a": 1}`))) - }) - }) - - Context("when a key mismatch is found", func() { - It("reports the first found mismatch", func() { - subject := MatchJSONMatcher{JSONToMatch: `5`} - actual := `7` - subject.Match(actual) - - failureMessage := subject.FailureMessage(`7`) - Expect(failureMessage).ToNot(ContainSubstring("first mismatched key")) - - subject = MatchJSONMatcher{JSONToMatch: `{"a": 1, "b.g": {"c": 2, "1": ["hello", "see ya"]}}`} - actual = `{"a": 1, "b.g": {"c": 2, "1": ["hello", "goodbye"]}}` - subject.Match(actual) - - failureMessage = subject.FailureMessage(actual) - Expect(failureMessage).To(ContainSubstring(`first mismatched key: "b.g"."1"[1]`)) - }) - }) - - Context("when the expected is not valid JSON", func() { - It("should error and explain why", func() { - success, err := (&MatchJSONMatcher{JSONToMatch: `{}`}).Match(`oops`) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("Actual 'oops' should be valid JSON")) - }) - }) - - Context("when the actual is not valid JSON", func() { - It("should error and explain why", func() { - success, err := (&MatchJSONMatcher{JSONToMatch: `oops`}).Match(`{}`) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("Expected 'oops' should be valid JSON")) - }) - }) - - Context("when the expected is neither a string nor a stringer nor a byte array", func() { - It("should error", func() { - success, err := (&MatchJSONMatcher{JSONToMatch: 2}).Match("{}") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n : 2")) - - success, err = (&MatchJSONMatcher{JSONToMatch: nil}).Match("{}") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n : nil")) - }) - }) - - Context("when the actual is neither a string nor a stringer nor a byte array", func() { - It("should error", func() { - success, err := (&MatchJSONMatcher{JSONToMatch: "{}"}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n : 2")) - - success, err = (&MatchJSONMatcher{JSONToMatch: "{}"}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n : nil")) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go deleted file mode 100644 index ac2538bb48..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("MatchRegexp", func() { - Context("when actual is a string", func() { - It("should match against the string", func() { - Expect(" a2!bla").Should(MatchRegexp(`\d!`)) - Expect(" a2!bla").ShouldNot(MatchRegexp(`[A-Z]`)) - }) - }) - - Context("when actual is a stringer", func() { - It("should call the stringer and match agains the returned string", func() { - Expect(&myStringer{a: "Abc3"}).Should(MatchRegexp(`[A-Z][a-z]+\d`)) - }) - }) - - Context("when the matcher is called with multiple arguments", func() { - It("should pass the string and arguments to sprintf", func() { - Expect(" a23!bla").Should(MatchRegexp(`\d%d!`, 3)) - }) - }) - - Context("when actual is neither a string nor a stringer", func() { - It("should error", func() { - success, err := (&MatchRegexpMatcher{Regexp: `\d`}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when the passed in regexp fails to compile", func() { - It("should error", func() { - success, err := (&MatchRegexpMatcher{Regexp: "("}).Match("Foo") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go deleted file mode 100644 index 0b559b22eb..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("MatchXMLMatcher", func() { - - var ( - sample_01 = readFileContents("test_data/xml/sample_01.xml") - sample_02 = readFileContents("test_data/xml/sample_02.xml") - sample_03 = readFileContents("test_data/xml/sample_03.xml") - sample_04 = readFileContents("test_data/xml/sample_04.xml") - sample_05 = readFileContents("test_data/xml/sample_05.xml") - sample_06 = readFileContents("test_data/xml/sample_06.xml") - sample_07 = readFileContents("test_data/xml/sample_07.xml") - sample_08 = readFileContents("test_data/xml/sample_08.xml") - sample_09 = readFileContents("test_data/xml/sample_09.xml") - sample_10 = readFileContents("test_data/xml/sample_10.xml") - sample_11 = readFileContents("test_data/xml/sample_11.xml") - ) - - Context("When passed stringifiables", func() { - It("matches documents regardless of the attribute order", func() { - a := `` - b := `` - Expect(b).Should(MatchXML(a)) - Expect(a).Should(MatchXML(b)) - }) - - It("should succeed if the XML matches", func() { - Expect(sample_01).Should(MatchXML(sample_01)) // same XML - Expect(sample_01).Should(MatchXML(sample_02)) // same XML with blank lines - Expect(sample_01).Should(MatchXML(sample_03)) // same XML with different formatting - Expect(sample_01).ShouldNot(MatchXML(sample_04)) // same structures with different values - Expect(sample_01).ShouldNot(MatchXML(sample_05)) // different structures - Expect(sample_06).ShouldNot(MatchXML(sample_07)) // same xml names with different namespaces - Expect(sample_07).ShouldNot(MatchXML(sample_08)) // same structures with different values - Expect(sample_09).ShouldNot(MatchXML(sample_10)) // same structures with different attribute values - Expect(sample_11).Should(MatchXML(sample_11)) // with non UTF-8 encoding - }) - - It("should work with byte arrays", func() { - Expect([]byte(sample_01)).Should(MatchXML([]byte(sample_01))) - Expect([]byte(sample_01)).Should(MatchXML(sample_01)) - Expect(sample_01).Should(MatchXML([]byte(sample_01))) - }) - }) - - Context("when the expected is not valid XML", func() { - It("should error and explain why", func() { - success, err := (&MatchXMLMatcher{XMLToMatch: sample_01}).Match(`oops`) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("Actual 'oops' should be valid XML")) - }) - }) - - Context("when the actual is not valid XML", func() { - It("should error and explain why", func() { - success, err := (&MatchXMLMatcher{XMLToMatch: `oops`}).Match(sample_01) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("Expected 'oops' should be valid XML")) - }) - }) - - Context("when the expected is neither a string nor a stringer nor a byte array", func() { - It("should error", func() { - success, err := (&MatchXMLMatcher{XMLToMatch: 2}).Match(sample_01) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n : 2")) - - success, err = (&MatchXMLMatcher{XMLToMatch: nil}).Match(sample_01) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n : nil")) - }) - }) - - Context("when the actual is neither a string nor a stringer nor a byte array", func() { - It("should error", func() { - success, err := (&MatchXMLMatcher{XMLToMatch: sample_01}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n : 2")) - - success, err = (&MatchXMLMatcher{XMLToMatch: sample_01}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n : nil")) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go deleted file mode 100644 index 1b0044fd09..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("MatchYAMLMatcher", func() { - Context("When passed stringifiables", func() { - It("should succeed if the YAML matches", func() { - Expect("---").Should(MatchYAML("")) - Expect("a: 1").Should(MatchYAML(`{"a":1}`)) - Expect("a: 1\nb: 2").Should(MatchYAML(`{"b":2, "a":1}`)) - }) - - It("should explain if the YAML does not match when it should", func() { - message := (&MatchYAMLMatcher{YAMLToMatch: "a: 1"}).FailureMessage("b: 2") - Expect(message).To(MatchRegexp(`Expected\s+: b: 2\s+to match YAML of\s+: a: 1`)) - }) - - It("should normalise the expected and actual when explaining if the YAML does not match when it should", func() { - message := (&MatchYAMLMatcher{YAMLToMatch: "a: 'one'"}).FailureMessage("{b: two}") - Expect(message).To(MatchRegexp(`Expected\s+: b: two\s+to match YAML of\s+: a: one`)) - }) - - It("should explain if the YAML matches when it should not", func() { - message := (&MatchYAMLMatcher{YAMLToMatch: "a: 1"}).NegatedFailureMessage("a: 1") - Expect(message).To(MatchRegexp(`Expected\s+: a: 1\s+not to match YAML of\s+: a: 1`)) - }) - - It("should normalise the expected and actual when explaining if the YAML matches when it should not", func() { - message := (&MatchYAMLMatcher{YAMLToMatch: "a: 'one'"}).NegatedFailureMessage("{a: one}") - Expect(message).To(MatchRegexp(`Expected\s+: a: one\s+not to match YAML of\s+: a: one`)) - }) - - It("should fail if the YAML does not match", func() { - Expect("a: 1").ShouldNot(MatchYAML(`{"b":2, "a":1}`)) - }) - - It("should work with byte arrays", func() { - Expect([]byte("a: 1")).Should(MatchYAML([]byte("a: 1"))) - Expect("a: 1").Should(MatchYAML([]byte("a: 1"))) - Expect([]byte("a: 1")).Should(MatchYAML("a: 1")) - }) - }) - - Context("when the expected is not valid YAML", func() { - It("should error and explain why", func() { - success, err := (&MatchYAMLMatcher{YAMLToMatch: ""}).Match("good:\nbad") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("Actual 'good:\nbad' should be valid YAML")) - }) - }) - - Context("when the actual is not valid YAML", func() { - It("should error and explain why", func() { - success, err := (&MatchYAMLMatcher{YAMLToMatch: "good:\nbad"}).Match("") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("Expected 'good:\nbad' should be valid YAML")) - }) - - It("errors when passed directly to Message", func() { - Expect(func() { - matcher := MatchYAMLMatcher{YAMLToMatch: "good"} - matcher.FailureMessage("good:\nbad") - }).To(Panic()) - }) - }) - - Context("when the expected is neither a string nor a stringer nor a byte array", func() { - It("should error", func() { - success, err := (&MatchYAMLMatcher{YAMLToMatch: 2}).Match("") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n : 2")) - - success, err = (&MatchYAMLMatcher{YAMLToMatch: nil}).Match("") - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n : nil")) - }) - }) - - Context("when the actual is neither a string nor a stringer nor a byte array", func() { - It("should error", func() { - success, err := (&MatchYAMLMatcher{YAMLToMatch: ""}).Match(2) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n : 2")) - - success, err = (&MatchYAMLMatcher{YAMLToMatch: ""}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n : nil")) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go b/vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go deleted file mode 100644 index b5f76c9959..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package matchers_test - -import ( - "fmt" - "io/ioutil" - "os" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type myStringer struct { - a string -} - -func (s *myStringer) String() string { - return s.a -} - -type StringAlias string - -type myCustomType struct { - s string - n int - f float32 - arr []string -} - -func Test(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Gomega Matchers") -} - -func readFileContents(filePath string) []byte { - f := openFile(filePath) - b, err := ioutil.ReadAll(f) - if err != nil { - panic(fmt.Errorf("failed to read file contents: %v", err)) - } - return b -} - -func openFile(filePath string) *os.File { - f, err := os.Open(filePath) - if err != nil { - panic(fmt.Errorf("failed to open file: %v", err)) - } - return f -} diff --git a/vendor/github.com/onsi/gomega/matchers/not_test.go b/vendor/github.com/onsi/gomega/matchers/not_test.go deleted file mode 100644 index 06d3ebd174..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/not_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("NotMatcher", func() { - Context("basic examples", func() { - It("works", func() { - Expect(input).To(Not(false1)) - Expect(input).To(Not(Not(true2))) - Expect(input).ToNot(Not(true3)) - Expect(input).ToNot(Not(Not(false1))) - Expect(input).To(Not(Not(Not(false2)))) - }) - - It("fails on error", func() { - failuresMessages := InterceptGomegaFailures(func() { - Expect(input).To(Not(Panic())) - }) - Expect(failuresMessages).To(Equal([]string{"PanicMatcher expects a function. Got:\n : hi"})) - }) - }) - - Context("De Morgan's laws", func() { - It("~(A && B) == ~A || ~B", func() { - Expect(input).To(Not(And(false1, false2))) - Expect(input).To(Or(Not(false1), Not(false2))) - }) - It("~(A || B) == ~A && ~B", func() { - Expect(input).To(Not(Or(false1, false2))) - Expect(input).To(And(Not(false1), Not(false2))) - }) - }) - - Context("failure messages are opposite of original matchers' failure messages", func() { - Context("when match fails", func() { - It("gives a descriptive message", func() { - verifyFailureMessage(Not(HaveLen(2)), input, "not to have length 2") - }) - }) - - Context("when match succeeds, but expected it to fail", func() { - It("gives a descriptive message", func() { - verifyFailureMessage(Not(Not(HaveLen(3))), input, "to have length 3") - }) - }) - }) - - Context("MatchMayChangeInTheFuture()", func() { - It("Propagates value from wrapped matcher", func() { - m := Not(Or()) // an empty Or() always returns false, and indicates it cannot change - Expect(m.Match("anything")).To(BeTrue()) - Expect(m.(*NotMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse()) - }) - It("Defaults to true", func() { - m := Not(Equal(1)) // Equal does not have this method - Expect(m.Match(2)).To(BeTrue()) - Expect(m.(*NotMatcher).MatchMayChangeInTheFuture(2)).To(BeTrue()) // defaults to true - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/or_test.go b/vendor/github.com/onsi/gomega/matchers/or_test.go deleted file mode 100644 index 1f6dfaf61d..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/or_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("OrMatcher", func() { - It("works with positive cases", func() { - Expect(input).To(Or(true1)) - Expect(input).To(Or(true1, true2)) - Expect(input).To(Or(true1, false1)) - Expect(input).To(Or(false1, true2)) - Expect(input).To(Or(true1, true2, true3)) - Expect(input).To(Or(true1, true2, false3)) - Expect(input).To(Or(true1, false2, true3)) - Expect(input).To(Or(false1, true2, true3)) - Expect(input).To(Or(true1, false2, false3)) - Expect(input).To(Or(false1, false2, true3)) - - // use alias - Expect(input).To(SatisfyAny(false1, false2, true3)) - }) - - It("stops on errors", func() { - failuresMessages := InterceptGomegaFailures(func() { - Expect(input).To(Or(Panic(), true1)) - }) - Expect(failuresMessages).To(Equal([]string{"PanicMatcher expects a function. Got:\n : hi"})) - }) - - It("works with negative cases", func() { - Expect(input).ToNot(Or()) - Expect(input).ToNot(Or(false1)) - Expect(input).ToNot(Or(false1, false2)) - Expect(input).ToNot(Or(false1, false2, false3)) - }) - - Context("failure messages", func() { - Context("when match fails", func() { - It("gives a descriptive message", func() { - verifyFailureMessage(Or(false1, false2), input, - "To satisfy at least one of these matchers: [%!s(*matchers.HaveLenMatcher=&{1}) %!s(*matchers.EqualMatcher=&{hip})]") - }) - }) - - Context("when match succeeds, but expected it to fail", func() { - It("gives a descriptive message", func() { - verifyFailureMessage(Not(Or(true1, true2)), input, `not to have length 2`) - }) - }) - }) - - Context("MatchMayChangeInTheFuture", func() { - Context("Match returned false", func() { - It("returns true if any of the matchers could change", func() { - // 3 matchers, all return false, and all could change - m := Or(BeNil(), Equal("hip"), HaveLen(1)) - Expect(m.Match("hi")).To(BeFalse()) - Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // all 3 of these matchers default to 'true' - }) - It("returns false if none of the matchers could change", func() { - // empty Or() has the property of never matching, and never can change since there are no sub-matchers that could change - m := Or() - Expect(m.Match("anything")).To(BeFalse()) - Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse()) - - // Or() with 3 sub-matchers that return false, and can't change - m = Or(Or(), Or(), Or()) - Expect(m.Match("hi")).To(BeFalse()) - Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // the 3 empty Or()'s won't change - }) - }) - Context("Match returned true", func() { - Context("returns value of the successful matcher", func() { - It("false if successful matcher not going to change", func() { - // 3 matchers: 1st returns false, 2nd returns true and is not going to change, 3rd is never called - m := Or(BeNil(), And(), Equal(1)) - Expect(m.Match("hi")).To(BeTrue()) - Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) - }) - It("true if successful matcher indicates it might change", func() { - // 3 matchers: 1st returns false, 2nd returns true and "might" change, 3rd is never called - m := Or(Not(BeNil()), Equal("hi"), Equal(1)) - Expect(m.Match("hi")).To(BeTrue()) - Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // Equal("hi") indicates it might change - }) - }) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go deleted file mode 100644 index 326bb10a48..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package matchers_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("Panic", func() { - Context("when passed something that's not a function that takes zero arguments and returns nothing", func() { - It("should error", func() { - success, err := (&PanicMatcher{}).Match("foo") - Expect(success).To(BeFalse()) - Expect(err).To(HaveOccurred()) - - success, err = (&PanicMatcher{}).Match(nil) - Expect(success).To(BeFalse()) - Expect(err).To(HaveOccurred()) - - success, err = (&PanicMatcher{}).Match(func(foo string) {}) - Expect(success).To(BeFalse()) - Expect(err).To(HaveOccurred()) - - success, err = (&PanicMatcher{}).Match(func() string { return "bar" }) - Expect(success).To(BeFalse()) - Expect(err).To(HaveOccurred()) - }) - }) - - Context("when passed a function of the correct type", func() { - It("should call the function and pass if the function panics", func() { - Expect(func() { panic("ack!") }).To(Panic()) - Expect(func() {}).NotTo(Panic()) - }) - }) - - Context("when assertion fails", func() { - It("prints the object passed to Panic when negative", func() { - failuresMessages := InterceptGomegaFailures(func() { - Expect(func() { panic("ack!") }).NotTo(Panic()) - }) - Expect(failuresMessages).To(ConsistOf(ContainSubstring("not to panic, but panicked with\n : ack!"))) - }) - - It("prints simple message when positive", func() { - failuresMessages := InterceptGomegaFailures(func() { - Expect(func() {}).To(Panic()) - }) - Expect(failuresMessages).To(ConsistOf(MatchRegexp("Expected\n\\s+: .+\nto panic"))) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go deleted file mode 100644 index cf04e85dd9..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go +++ /dev/null @@ -1,304 +0,0 @@ -package matchers_test - -import ( - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -type kungFuActor interface { - DrunkenMaster() bool -} - -type jackie struct { - name string -} - -func (j *jackie) DrunkenMaster() bool { - return true -} - -type someError struct{ s string } - -func (e *someError) Error() string { return e.s } - -var _ = Describe("ReceiveMatcher", func() { - Context("with no argument", func() { - Context("for a buffered channel", func() { - It("should succeed", func() { - channel := make(chan bool, 1) - - Expect(channel).ShouldNot(Receive()) - - channel <- true - - Expect(channel).Should(Receive()) - }) - }) - - Context("for an unbuffered channel", func() { - It("should succeed (eventually)", func() { - channel := make(chan bool) - - Expect(channel).ShouldNot(Receive()) - - go func() { - time.Sleep(10 * time.Millisecond) - channel <- true - }() - - Eventually(channel).Should(Receive()) - }) - }) - }) - - Context("with a pointer argument", func() { - Context("of the correct type", func() { - Context("when the channel has an interface type", func() { - It("should write the value received on the channel to the pointer", func() { - channel := make(chan error, 1) - - var value *someError - - Ω(channel).ShouldNot(Receive(&value)) - Ω(value).Should(BeZero()) - - channel <- &someError{"boooom!"} - - Ω(channel).Should(Receive(&value)) - Ω(value).Should(MatchError("boooom!")) - }) - }) - }) - - Context("of the correct type", func() { - It("should write the value received on the channel to the pointer", func() { - channel := make(chan int, 1) - - var value int - - Expect(channel).ShouldNot(Receive(&value)) - Expect(value).Should(BeZero()) - - channel <- 17 - - Expect(channel).Should(Receive(&value)) - Expect(value).Should(Equal(17)) - }) - }) - - Context("to various types of objects", func() { - It("should work", func() { - //channels of strings - stringChan := make(chan string, 1) - stringChan <- "foo" - - var s string - Expect(stringChan).Should(Receive(&s)) - Expect(s).Should(Equal("foo")) - - //channels of slices - sliceChan := make(chan []bool, 1) - sliceChan <- []bool{true, true, false} - - var sl []bool - Expect(sliceChan).Should(Receive(&sl)) - Expect(sl).Should(Equal([]bool{true, true, false})) - - //channels of channels - chanChan := make(chan chan bool, 1) - c := make(chan bool) - chanChan <- c - - var receivedC chan bool - Expect(chanChan).Should(Receive(&receivedC)) - Expect(receivedC).Should(Equal(c)) - - //channels of interfaces - jackieChan := make(chan kungFuActor, 1) - aJackie := &jackie{name: "Jackie Chan"} - jackieChan <- aJackie - - var theJackie kungFuActor - Expect(jackieChan).Should(Receive(&theJackie)) - Expect(theJackie).Should(Equal(aJackie)) - }) - }) - - Context("of the wrong type", func() { - It("should error", func() { - channel := make(chan int, 1) - channel <- 10 - - var incorrectType bool - - success, err := (&ReceiveMatcher{Arg: &incorrectType}).Match(channel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - var notAPointer int - success, err = (&ReceiveMatcher{Arg: notAPointer}).Match(channel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - }) - - Context("with a matcher", func() { - It("should defer to the underlying matcher", func() { - intChannel := make(chan int, 1) - intChannel <- 3 - Expect(intChannel).Should(Receive(Equal(3))) - - intChannel <- 2 - Expect(intChannel).ShouldNot(Receive(Equal(3))) - - stringChannel := make(chan []string, 1) - stringChannel <- []string{"foo", "bar", "baz"} - Expect(stringChannel).Should(Receive(ContainElement(ContainSubstring("fo")))) - - stringChannel <- []string{"foo", "bar", "baz"} - Expect(stringChannel).ShouldNot(Receive(ContainElement(ContainSubstring("archipelago")))) - }) - - It("should defer to the underlying matcher for the message", func() { - matcher := Receive(Equal(3)) - channel := make(chan int, 1) - channel <- 2 - matcher.Match(channel) - Expect(matcher.FailureMessage(channel)).Should(MatchRegexp(`Expected\s+: 2\s+to equal\s+: 3`)) - - channel <- 3 - matcher.Match(channel) - Expect(matcher.NegatedFailureMessage(channel)).Should(MatchRegexp(`Expected\s+: 3\s+not to equal\s+: 3`)) - }) - - It("should work just fine with Eventually", func() { - stringChannel := make(chan string) - - go func() { - time.Sleep(5 * time.Millisecond) - stringChannel <- "A" - time.Sleep(5 * time.Millisecond) - stringChannel <- "B" - }() - - Eventually(stringChannel).Should(Receive(Equal("B"))) - }) - - Context("if the matcher errors", func() { - It("should error", func() { - channel := make(chan int, 1) - channel <- 3 - success, err := (&ReceiveMatcher{Arg: ContainSubstring("three")}).Match(channel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("if nothing is received", func() { - It("should fail", func() { - channel := make(chan int, 1) - success, err := (&ReceiveMatcher{Arg: Equal(1)}).Match(channel) - Expect(success).Should(BeFalse()) - Expect(err).ShouldNot(HaveOccurred()) - }) - }) - }) - - Context("When actual is a *closed* channel", func() { - Context("for a buffered channel", func() { - It("should work until it hits the end of the buffer", func() { - channel := make(chan bool, 1) - channel <- true - - close(channel) - - Expect(channel).Should(Receive()) - Expect(channel).ShouldNot(Receive()) - }) - }) - - Context("for an unbuffered channel", func() { - It("should always fail", func() { - channel := make(chan bool) - close(channel) - - Expect(channel).ShouldNot(Receive()) - }) - }) - }) - - Context("When actual is a send-only channel", func() { - It("should error", func() { - channel := make(chan bool) - - var writerChannel chan<- bool - writerChannel = channel - - success, err := (&ReceiveMatcher{}).Match(writerChannel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Context("when acutal is a non-channel", func() { - It("should error", func() { - var nilChannel chan bool - - success, err := (&ReceiveMatcher{}).Match(nilChannel) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&ReceiveMatcher{}).Match(nil) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - - success, err = (&ReceiveMatcher{}).Match(3) - Expect(success).Should(BeFalse()) - Expect(err).Should(HaveOccurred()) - }) - }) - - Describe("when used with eventually and a custom matcher", func() { - It("should return the matcher's error when a failing value is received on the channel, instead of the must receive something failure", func() { - failures := InterceptGomegaFailures(func() { - c := make(chan string, 0) - Eventually(c, 0.01).Should(Receive(Equal("hello"))) - }) - Expect(failures[0]).Should(ContainSubstring("When passed a matcher, ReceiveMatcher's channel *must* receive something.")) - - failures = InterceptGomegaFailures(func() { - c := make(chan string, 1) - c <- "hi" - Eventually(c, 0.01).Should(Receive(Equal("hello"))) - }) - Expect(failures[0]).Should(ContainSubstring(": hello")) - }) - }) - - Describe("Bailing early", func() { - It("should bail early when passed a closed channel", func() { - c := make(chan bool) - close(c) - - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(c).Should(Receive()) - }) - Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond)) - Expect(failures).Should(HaveLen(1)) - }) - - It("should bail early when passed a non-channel", func() { - t := time.Now() - failures := InterceptGomegaFailures(func() { - Eventually(3).Should(Receive()) - }) - Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond)) - Expect(failures).Should(HaveLen(1)) - }) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go deleted file mode 100644 index e42dd8a6ea..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package matchers_test - -import ( - "errors" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" - "regexp" -) - -func Erroring() error { - return errors.New("bam") -} - -func NotErroring() error { - return nil -} - -type AnyType struct{} - -func Invalid() *AnyType { - return nil -} - -var _ = Describe("Succeed", func() { - It("should succeed if the function succeeds", func() { - Expect(NotErroring()).Should(Succeed()) - }) - - It("should succeed (in the negated) if the function errored", func() { - Expect(Erroring()).ShouldNot(Succeed()) - }) - - It("should not if passed a non-error", func() { - success, err := (&SucceedMatcher{}).Match(Invalid()) - Expect(success).Should(BeFalse()) - Expect(err).Should(MatchError("Expected an error-type. Got:\n <*matchers_test.AnyType | 0x0>: nil")) - }) - - It("doesn't support non-error type", func() { - success, err := (&SucceedMatcher{}).Match(AnyType{}) - Expect(success).Should(BeFalse()) - Expect(err).Should(MatchError("Expected an error-type. Got:\n : {}")) - }) - - It("doesn't support non-error pointer type", func() { - success, err := (&SucceedMatcher{}).Match(&AnyType{}) - Expect(success).Should(BeFalse()) - Expect(err).Should(MatchError(MatchRegexp(`Expected an error-type. Got:\n <*matchers_test.AnyType | 0x[[:xdigit:]]+>: {}`))) - }) - - It("should not succeed with pointer types that conform to error interface", func() { - err := &CustomErr{"ohai"} - Expect(err).ShouldNot(Succeed()) - }) - - It("should succeed with nil pointers to types that conform to error interface", func() { - var err *CustomErr = nil - Expect(err).Should(Succeed()) - }) - - It("builds failure message", func() { - actual := Succeed().FailureMessage(errors.New("oops")) - actual = regexp.MustCompile(" 0x.*>").ReplaceAllString(actual, " 0x00000000>") - Expect(actual).To(Equal("Expected success, but got an error:\n <*errors.errorString | 0x00000000>: {s: \"oops\"}\n oops")) - }) - - It("builds negated failure message", func() { - actual := Succeed().NegatedFailureMessage(123) - Expect(actual).To(Equal("Expected failure, but got no error.")) - }) -}) diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml deleted file mode 100644 index 90f0a1b454..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml +++ /dev/null @@ -1,6 +0,0 @@ - - Tove - Jani - Reminder - Don't forget me this weekend! - \ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml deleted file mode 100644 index 3863b83c37..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - Tove - Jani - Reminder - Don't forget me this weekend! - - diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml deleted file mode 100644 index a491c213c5..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml +++ /dev/null @@ -1 +0,0 @@ - Tove Jani Reminder Don't forget me this weekend! diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml deleted file mode 100644 index dcfd3db03c..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml +++ /dev/null @@ -1,6 +0,0 @@ - - Tove - John - Doe - Don't forget me this weekend! - \ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml deleted file mode 100644 index de15a6a558..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - Empire Burlesque - Bob Dylan - USA - Columbia - 10.90 - 1985 - - - Hide your heart - Bonnie Tyler - UK - CBS Records - 9.90 - 1988 - - - Greatest Hits - Dolly Parton - USA - RCA - 9.90 - 1982 - - - Still got the blues - Gary Moore - UK - Virgin records - 10.20 - 1990 - - - Eros - Eros Ramazzotti - EU - BMG - 9.90 - 1997 - - - One night only - Bee Gees - UK - Polydor - 10.90 - 1998 - - - Sylvias Mother - Dr.Hook - UK - CBS - 8.10 - 1973 - - - Maggie May - Rod Stewart - UK - Pickwick - 8.50 - 1990 - - - Romanza - Andrea Bocelli - EU - Polydor - 10.80 - 1996 - - - When a man loves a woman - Percy Sledge - USA - Atlantic - 8.70 - 1987 - - - Black angel - Savage Rose - EU - Mega - 10.90 - 1995 - - - 1999 Grammy Nominees - Many - USA - Grammy - 10.20 - 1999 - - - For the good times - Kenny Rogers - UK - Mucik Master - 8.70 - 1995 - - - Big Willie style - Will Smith - USA - Columbia - 9.90 - 1997 - - - Tupelo Honey - Van Morrison - UK - Polydor - 8.20 - 1971 - - - Soulsville - Jorn Hoel - Norway - WEA - 7.90 - 1996 - - - The very best of - Cat Stevens - UK - Island - 8.90 - 1990 - - - Stop - Sam Brown - UK - A and M - 8.90 - 1988 - - - Bridge of Spies - T'Pau - UK - Siren - 7.90 - 1987 - - - Private Dancer - Tina Turner - UK - Capitol - 8.90 - 1983 - - - Midt om natten - Kim Larsen - EU - Medley - 7.80 - 1983 - - - Pavarotti Gala Concert - Luciano Pavarotti - UK - DECCA - 9.90 - 1991 - - - The dock of the bay - Otis Redding - USA - Stax Records - 7.90 - 1968 - - - Picture book - Simply Red - EU - Elektra - 7.20 - 1985 - - - Red - The Communards - UK - London - 7.80 - 1987 - - - Unchain my heart - Joe Cocker - USA - EMI - 8.20 - 1987 - - diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml deleted file mode 100644 index 4ba90fb97d..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - -
ApplesBananas
- - African Coffee Table - 80 - 120 -
-
\ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml deleted file mode 100644 index 34b9e97758..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - Apples - Bananas - - - - African Coffee Table - 80 - 120 - - \ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml deleted file mode 100644 index ccaee4e1ae..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - Apples - Oranges - - - - African Coffee Table - 80 - 120 - - \ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml deleted file mode 100644 index 531f84d3f9..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml +++ /dev/null @@ -1,4 +0,0 @@ - - Foo - Bar - \ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml deleted file mode 100644 index b1e1e1fbe1..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml +++ /dev/null @@ -1,4 +0,0 @@ - - Foo - Bar - \ No newline at end of file diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml deleted file mode 100644 index 3132b0f904..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - Tove - Jani - Reminder - Don't forget me this weekend! - diff --git a/vendor/github.com/onsi/gomega/matchers/with_transform_test.go b/vendor/github.com/onsi/gomega/matchers/with_transform_test.go deleted file mode 100644 index e52bf8e631..0000000000 --- a/vendor/github.com/onsi/gomega/matchers/with_transform_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package matchers_test - -import ( - "errors" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/matchers" -) - -var _ = Describe("WithTransformMatcher", func() { - - var plus1 = func(i int) int { return i + 1 } - - Context("Panic if transform function invalid", func() { - panicsWithTransformer := func(transform interface{}) { - ExpectWithOffset(1, func() { WithTransform(transform, nil) }).To(Panic()) - } - It("nil", func() { - panicsWithTransformer(nil) - }) - Context("Invalid number of args, but correct return value count", func() { - It("zero", func() { - panicsWithTransformer(func() int { return 5 }) - }) - It("two", func() { - panicsWithTransformer(func(i, j int) int { return 5 }) - }) - }) - Context("Invalid number of return values, but correct number of arguments", func() { - It("zero", func() { - panicsWithTransformer(func(i int) {}) - }) - It("two", func() { - panicsWithTransformer(func(i int) (int, int) { return 5, 6 }) - }) - }) - }) - - It("works with positive cases", func() { - Expect(1).To(WithTransform(plus1, Equal(2))) - Expect(1).To(WithTransform(plus1, WithTransform(plus1, Equal(3)))) - Expect(1).To(WithTransform(plus1, And(Equal(2), BeNumerically(">", 1)))) - - // transform expects custom type - type S struct { - A int - B string - } - transformer := func(s S) string { return s.B } - Expect(S{1, "hi"}).To(WithTransform(transformer, Equal("hi"))) - - // transform expects interface - errString := func(e error) string { return e.Error() } - Expect(errors.New("abc")).To(WithTransform(errString, Equal("abc"))) - }) - - It("works with negative cases", func() { - Expect(1).ToNot(WithTransform(plus1, Equal(3))) - Expect(1).ToNot(WithTransform(plus1, WithTransform(plus1, Equal(2)))) - }) - - Context("failure messages", func() { - Context("when match fails", func() { - It("gives a descriptive message", func() { - m := WithTransform(plus1, Equal(3)) - Expect(m.Match(1)).To(BeFalse()) - Expect(m.FailureMessage(1)).To(Equal("Expected\n : 2\nto equal\n : 3")) - }) - }) - - Context("when match succeeds, but expected it to fail", func() { - It("gives a descriptive message", func() { - m := Not(WithTransform(plus1, Equal(3))) - Expect(m.Match(2)).To(BeFalse()) - Expect(m.FailureMessage(2)).To(Equal("Expected\n : 3\nnot to equal\n : 3")) - }) - }) - - Context("actual value is incompatible with transform function's argument type", func() { - It("gracefully fails if transform cannot be performed", func() { - m := WithTransform(plus1, Equal(3)) - result, err := m.Match("hi") // give it a string but transform expects int; doesn't panic - Expect(result).To(BeFalse()) - Expect(err).To(MatchError("Transform function expects 'int' but we have 'string'")) - }) - }) - }) - - Context("MatchMayChangeInTheFuture()", func() { - It("Propagates value from wrapped matcher on the transformed value", func() { - m := WithTransform(plus1, Or()) // empty Or() always returns false, and indicates it cannot change - Expect(m.Match(1)).To(BeFalse()) - Expect(m.(*WithTransformMatcher).MatchMayChangeInTheFuture(1)).To(BeFalse()) // empty Or() indicates cannot change - }) - It("Defaults to true", func() { - m := WithTransform(plus1, Equal(2)) // Equal does not have this method - Expect(m.Match(1)).To(BeTrue()) - Expect(m.(*WithTransformMatcher).MatchMayChangeInTheFuture(1)).To(BeTrue()) // defaults to true - }) - }) -}) diff --git a/vendor/github.com/openshift/imagebuilder/README.md b/vendor/github.com/openshift/imagebuilder/README.md index f26b4a7e0b..fd96ed9401 100644 --- a/vendor/github.com/openshift/imagebuilder/README.md +++ b/vendor/github.com/openshift/imagebuilder/README.md @@ -1,4 +1,4 @@ -Docker / OCI Image Builder +OCI Image Builder ========================== [![Go Report Card](https://goreportcard.com/badge/github.com/openshift/imagebuilder)](https://goreportcard.com/report/github.com/openshift/imagebuilder) @@ -6,22 +6,22 @@ Docker / OCI Image Builder [![Travis](https://travis-ci.org/openshift/imagebuilder.svg?branch=master)](https://travis-ci.org/openshift/imagebuilder) [![Join the chat at freenode:openshift-dev](https://img.shields.io/badge/irc-freenode%3A%20%23openshift--dev-blue.svg)](http://webchat.freenode.net/?channels=%23openshift-dev) -Note: this library is beta and may contain bugs that prevent images from being identical to Docker build. Test your images (and add to our conformance suite)! +Please test your images (and add to our conformance suite)! -This library supports using the Dockerfile syntax to build Docker -compatible images, without invoking Docker build. It is intended to give -clients more control over how a Docker build is run, including: +This library supports using the Dockerfile syntax to build OCI & Docker +compatible images, without invoking a container build command such as `buildah bud` or `docker build`. It is intended to give +clients more control over how they build container images, including: * Instead of building one layer per line, run all instructions in the same container -* Set Docker HostConfig settings like network and memory controls that - are not available when running Docker builds +* Set HostConfig settings like network and memory controls that + are not available when running container builds * Mount external files into the build that are not persisted as part of the final image (i.e. "secrets") * If there are no RUN commands in the Dockerfile, the container is created and committed, but never started. -The final image should be 99.9% compatible with regular docker builds, +The final image should be 99.9% compatible with regular container builds, but bugs are always possible. Future goals include: @@ -54,9 +54,6 @@ $ imagebuilder --mount ~/secrets/private.key:/etc/keys/private.key path/to/my/co Any processes in the Dockerfile will have access to `/etc/keys/private.key`, but that file will not be part of the committed image. -Running `--mount` requires Docker 1.10 or newer, as it uses a Docker volume to hold the mounted files and the volume API was not -available in earlier versions. - You can also customize which Dockerfile is run, or run multiple Dockerfiles in sequence (the FROM is ignored on later files): diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go index 16682af7d7..86b139b653 100644 --- a/vendor/github.com/openshift/imagebuilder/builder.go +++ b/vendor/github.com/openshift/imagebuilder/builder.go @@ -13,8 +13,8 @@ import ( docker "github.com/fsouza/go-dockerclient" - "github.com/docker/docker/builder/dockerfile/command" - "github.com/docker/docker/builder/dockerfile/parser" + "github.com/openshift/imagebuilder/dockerfile/command" + "github.com/openshift/imagebuilder/dockerfile/parser" ) // Copy defines a copy operation required on the container. diff --git a/vendor/github.com/openshift/imagebuilder/dockerfile/NOTICE b/vendor/github.com/openshift/imagebuilder/dockerfile/NOTICE new file mode 100644 index 0000000000..519a7e9950 --- /dev/null +++ b/vendor/github.com/openshift/imagebuilder/dockerfile/NOTICE @@ -0,0 +1,26 @@ +Source files in this directory and all sub-directories have been +copied from github.com/docker/docker/builder/dockerfile and are +Licensed under the Apache License Version 2.0. + +Note that the fork of github.com/docker/docker used commit +b68221c37ee597950364788204546f9c9d0e46a1. + +Docker +Copyright 2012-2017 Docker, Inc. + +This product includes software developed at Docker, Inc. (https://www.docker.com). + +This product contains software (https://github.com/kr/pty) developed +by Keith Rarick, licensed under the MIT License. + +The following is courtesy of our legal counsel: + + +Use and transfer of Docker may be subject to certain restrictions by the +United States and other governments. +It is your responsibility to ensure that your use and/or transfer does not +violate applicable laws. + +For more information, please see https://www.bis.doc.gov + +See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. diff --git a/vendor/github.com/docker/docker/builder/dockerfile/command/command.go b/vendor/github.com/openshift/imagebuilder/dockerfile/command/command.go similarity index 100% rename from vendor/github.com/docker/docker/builder/dockerfile/command/command.go rename to vendor/github.com/openshift/imagebuilder/dockerfile/command/command.go diff --git a/vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go b/vendor/github.com/openshift/imagebuilder/dockerfile/parser/line_parsers.go similarity index 99% rename from vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go rename to vendor/github.com/openshift/imagebuilder/dockerfile/parser/line_parsers.go index 2c375b74e4..82d912b26e 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/parser/line_parsers.go +++ b/vendor/github.com/openshift/imagebuilder/dockerfile/parser/line_parsers.go @@ -15,7 +15,7 @@ import ( "unicode" "unicode/utf8" - "github.com/docker/docker/builder/dockerfile/command" + "github.com/openshift/imagebuilder/dockerfile/command" ) var ( diff --git a/vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go b/vendor/github.com/openshift/imagebuilder/dockerfile/parser/parser.go similarity index 94% rename from vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go rename to vendor/github.com/openshift/imagebuilder/dockerfile/parser/parser.go index 822c42b41a..0223963e1c 100644 --- a/vendor/github.com/docker/docker/builder/dockerfile/parser/parser.go +++ b/vendor/github.com/openshift/imagebuilder/dockerfile/parser/parser.go @@ -12,7 +12,7 @@ import ( "strings" "unicode" - "github.com/docker/docker/builder/dockerfile/command" + "github.com/openshift/imagebuilder/dockerfile/command" "github.com/docker/docker/pkg/system" "github.com/pkg/errors" ) @@ -91,6 +91,9 @@ var ( // DefaultEscapeToken is the default escape token const DefaultEscapeToken = '\\' +// defaultPlatformToken is the platform assumed for the build if not explicitly provided +var defaultPlatformToken = runtime.GOOS + // Directive is the structure used during a build run to hold the state of // parsing directives. type Directive struct { @@ -140,7 +143,7 @@ func (d *Directive) possibleParserDirective(line string) error { if len(tecMatch) != 0 { for i, n := range tokenEscapeCommand.SubexpNames() { if n == "escapechar" { - if d.escapeSeen { + if d.escapeSeen == true { return errors.New("only one escape parser directive can be used") } d.escapeSeen = true @@ -149,13 +152,14 @@ func (d *Directive) possibleParserDirective(line string) error { } } - // Only recognise a platform token if LCOW is supported + // TODO @jhowardmsft LCOW Support: Eventually this check can be removed, + // but only recognise a platform token if running in LCOW mode. if system.LCOWSupported() { tpcMatch := tokenPlatformCommand.FindStringSubmatch(strings.ToLower(line)) if len(tpcMatch) != 0 { for i, n := range tokenPlatformCommand.SubexpNames() { if n == "platform" { - if d.platformSeen { + if d.platformSeen == true { return errors.New("only one platform parser directive can be used") } d.platformSeen = true @@ -173,6 +177,7 @@ func (d *Directive) possibleParserDirective(line string) error { func NewDefaultDirective() *Directive { directive := Directive{} directive.setEscapeToken(string(DefaultEscapeToken)) + directive.setPlatformToken(defaultPlatformToken) return &directive } @@ -237,10 +242,8 @@ func newNodeFromLine(line string, directive *Directive) (*Node, error) { type Result struct { AST *Node EscapeToken rune - // TODO @jhowardmsft - see https://github.com/moby/moby/issues/34617 - // This next field will be removed in a future update for LCOW support. - OS string - Warnings []string + Platform string + Warnings []string } // PrintWarnings to the writer @@ -287,10 +290,6 @@ func Parse(rwc io.Reader) (*Result, error) { } currentLine++ - if isComment(scanner.Bytes()) { - // original line was a comment (processLine strips comments) - continue - } if isEmptyContinuationLine(bytesRead) { hasEmptyContinuationLine = true continue @@ -320,7 +319,7 @@ func Parse(rwc io.Reader) (*Result, error) { AST: root, Warnings: warnings, EscapeToken: d.escapeToken, - OS: d.platformToken, + Platform: d.platformToken, }, nil } @@ -332,12 +331,8 @@ func trimWhitespace(src []byte) []byte { return bytes.TrimLeftFunc(src, unicode.IsSpace) } -func isComment(line []byte) bool { - return tokenComment.Match(trimWhitespace(line)) -} - func isEmptyContinuationLine(line []byte) bool { - return len(trimWhitespace(line)) == 0 + return len(trimComments(trimWhitespace(line))) == 0 } var utf8bom = []byte{0xEF, 0xBB, 0xBF} diff --git a/vendor/github.com/docker/docker/builder/dockerfile/parser/split_command.go b/vendor/github.com/openshift/imagebuilder/dockerfile/parser/split_command.go similarity index 100% rename from vendor/github.com/docker/docker/builder/dockerfile/parser/split_command.go rename to vendor/github.com/openshift/imagebuilder/dockerfile/parser/split_command.go diff --git a/vendor/github.com/openshift/imagebuilder/evaluator.go b/vendor/github.com/openshift/imagebuilder/evaluator.go index e1cd5d6d65..1ea3584518 100644 --- a/vendor/github.com/openshift/imagebuilder/evaluator.go +++ b/vendor/github.com/openshift/imagebuilder/evaluator.go @@ -5,8 +5,8 @@ import ( "io" "strings" - "github.com/docker/docker/builder/dockerfile/command" - "github.com/docker/docker/builder/dockerfile/parser" + "github.com/openshift/imagebuilder/dockerfile/command" + "github.com/openshift/imagebuilder/dockerfile/parser" ) // ParseDockerfile parses the provided stream as a canonical Dockerfile diff --git a/vendor/github.com/openshift/imagebuilder/vendor.conf b/vendor/github.com/openshift/imagebuilder/vendor.conf new file mode 100644 index 0000000000..39b216feb4 --- /dev/null +++ b/vendor/github.com/openshift/imagebuilder/vendor.conf @@ -0,0 +1,21 @@ +github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 +github.com/containerd/continuity 004b46473808b3e7a4a3049c20e4376c91eb966d +github.com/docker/docker b68221c37ee597950364788204546f9c9d0e46a1 +github.com/docker/go-connections 97c2040d34dfae1d1b1275fa3a78dbdd2f41cf7e +github.com/docker/go-units 2fb04c6466a548a03cb009c5569ee1ab1e35398e +github.com/fsouza/go-dockerclient openshift-4.0 https://github.com/openshift/go-dockerclient.git +github.com/gogo/protobuf c5a62797aee0054613cc578653a16c6237fef080 +github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998 +github.com/golang/protobuf v1.3.0 +github.com/konsorten/go-windows-terminal-sequences f55edac94c9bbba5d6182a4be46d86a2c9b5b50e +github.com/Microsoft/go-winio 1a8911d1ed007260465c3bfbbc785ac6915a0bb8 +github.com/Nvveen/Gotty cd527374f1e5bff4938207604a14f2e38a9cf512 +github.com/opencontainers/go-digest ac19fd6e7483ff933754af248d80be865e543d22 +github.com/opencontainers/image-spec 243ea084a44451d27322fed02b682d99e2af3ba9 +github.com/opencontainers/runc 923a8f8a9a07aceada5fc48c4d37e905d9b019b5 +github.com/pkg/errors 27936f6d90f9c8e1145f11ed52ffffbfdb9e0af7 +github.com/sirupsen/logrus d7b6bf5e4d26448fd977d07d745a2a66097ddecb +golang.org/x/crypto ff983b9c42bc9fbf91556e191cc8efb585c16908 +golang.org/x/net 45ffb0cd1ba084b73e26dee67e667e1be5acce83 +golang.org/x/sync 37e7f081c4d4c64e13b10787722085407fe5d15f +golang.org/x/sys 7fbe1cd0fcc20051e1fcb87fbabec4a1bacaaeba diff --git a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go deleted file mode 100644 index 37dc0cfdb5..0000000000 --- a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ctxhttp provides helper functions for performing context-aware HTTP requests. -package ctxhttp // import "golang.org/x/net/context/ctxhttp" - -import ( - "context" - "io" - "net/http" - "net/url" - "strings" -) - -// Do sends an HTTP request with the provided http.Client and returns -// an HTTP response. -// -// If the client is nil, http.DefaultClient is used. -// -// The provided ctx must be non-nil. If it is canceled or times out, -// ctx.Err() will be returned. -func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { - if client == nil { - client = http.DefaultClient - } - resp, err := client.Do(req.WithContext(ctx)) - // If we got an error, and the context has been canceled, - // the context's error is probably more useful. - if err != nil { - select { - case <-ctx.Done(): - err = ctx.Err() - default: - } - } - return resp, err -} - -// Get issues a GET request via the Do function. -func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - return Do(ctx, client, req) -} - -// Head issues a HEAD request via the Do function. -func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { - req, err := http.NewRequest("HEAD", url, nil) - if err != nil { - return nil, err - } - return Do(ctx, client, req) -} - -// Post issues a POST request via the Do function. -func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { - req, err := http.NewRequest("POST", url, body) - if err != nil { - return nil, err - } - req.Header.Set("Content-Type", bodyType) - return Do(ctx, client, req) -} - -// PostForm issues a POST request via the Do function. -func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { - return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) -}