github.com/kim0/docker@v0.6.2-0.20161130212042-4addda3f07e7/api/types/client.go (about) 1 package types 2 3 import ( 4 "bufio" 5 "io" 6 "net" 7 8 "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/api/types/filters" 10 "github.com/docker/go-units" 11 ) 12 13 // CheckpointCreateOptions holds parameters to create a checkpoint from a container 14 type CheckpointCreateOptions struct { 15 CheckpointID string 16 CheckpointDir string 17 Exit bool 18 } 19 20 // CheckpointListOptions holds parameters to list checkpoints for a container 21 type CheckpointListOptions struct { 22 CheckpointDir string 23 } 24 25 // CheckpointDeleteOptions holds parameters to delete a checkpoint from a container 26 type CheckpointDeleteOptions struct { 27 CheckpointID string 28 CheckpointDir string 29 } 30 31 // ContainerAttachOptions holds parameters to attach to a container. 32 type ContainerAttachOptions struct { 33 Stream bool 34 Stdin bool 35 Stdout bool 36 Stderr bool 37 DetachKeys string 38 Logs bool 39 } 40 41 // ContainerCommitOptions holds parameters to commit changes into a container. 42 type ContainerCommitOptions struct { 43 Reference string 44 Comment string 45 Author string 46 Changes []string 47 Pause bool 48 Config *container.Config 49 } 50 51 // ContainerExecInspect holds information returned by exec inspect. 52 type ContainerExecInspect struct { 53 ExecID string 54 ContainerID string 55 Running bool 56 ExitCode int 57 Pid int 58 } 59 60 // ContainerListOptions holds parameters to list containers with. 61 type ContainerListOptions struct { 62 Quiet bool 63 Size bool 64 All bool 65 Latest bool 66 Since string 67 Before string 68 Limit int 69 Filter filters.Args 70 } 71 72 // ContainerLogsOptions holds parameters to filter logs with. 73 type ContainerLogsOptions struct { 74 ShowStdout bool 75 ShowStderr bool 76 Since string 77 Timestamps bool 78 Follow bool 79 Tail string 80 Details bool 81 } 82 83 // ContainerRemoveOptions holds parameters to remove containers. 84 type ContainerRemoveOptions struct { 85 RemoveVolumes bool 86 RemoveLinks bool 87 Force bool 88 } 89 90 // ContainerStartOptions holds parameters to start containers. 91 type ContainerStartOptions struct { 92 CheckpointID string 93 CheckpointDir string 94 } 95 96 // CopyToContainerOptions holds information 97 // about files to copy into a container 98 type CopyToContainerOptions struct { 99 AllowOverwriteDirWithFile bool 100 } 101 102 // EventsOptions holds parameters to filter events with. 103 type EventsOptions struct { 104 Since string 105 Until string 106 Filters filters.Args 107 } 108 109 // NetworkListOptions holds parameters to filter the list of networks with. 110 type NetworkListOptions struct { 111 Filters filters.Args 112 } 113 114 // HijackedResponse holds connection information for a hijacked request. 115 type HijackedResponse struct { 116 Conn net.Conn 117 Reader *bufio.Reader 118 } 119 120 // Close closes the hijacked connection and reader. 121 func (h *HijackedResponse) Close() { 122 h.Conn.Close() 123 } 124 125 // CloseWriter is an interface that implements structs 126 // that close input streams to prevent from writing. 127 type CloseWriter interface { 128 CloseWrite() error 129 } 130 131 // CloseWrite closes a readWriter for writing. 132 func (h *HijackedResponse) CloseWrite() error { 133 if conn, ok := h.Conn.(CloseWriter); ok { 134 return conn.CloseWrite() 135 } 136 return nil 137 } 138 139 // ImageBuildOptions holds the information 140 // necessary to build images. 141 type ImageBuildOptions struct { 142 Tags []string 143 SuppressOutput bool 144 RemoteContext string 145 NoCache bool 146 Remove bool 147 ForceRemove bool 148 PullParent bool 149 Isolation container.Isolation 150 CPUSetCPUs string 151 CPUSetMems string 152 CPUShares int64 153 CPUQuota int64 154 CPUPeriod int64 155 Memory int64 156 MemorySwap int64 157 CgroupParent string 158 NetworkMode string 159 ShmSize int64 160 Dockerfile string 161 Ulimits []*units.Ulimit 162 BuildArgs map[string]string 163 AuthConfigs map[string]AuthConfig 164 Context io.Reader 165 Labels map[string]string 166 // squash the resulting image's layers to the parent 167 // preserves the original image and creates a new one from the parent with all 168 // the changes applied to a single layer 169 Squash bool 170 // CacheFrom specifies images that are used for matching cache. Images 171 // specified here do not need to have a valid parent chain to match cache. 172 CacheFrom []string 173 SecurityOpt []string 174 } 175 176 // ImageBuildResponse holds information 177 // returned by a server after building 178 // an image. 179 type ImageBuildResponse struct { 180 Body io.ReadCloser 181 OSType string 182 } 183 184 // ImageCreateOptions holds information to create images. 185 type ImageCreateOptions struct { 186 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 187 } 188 189 // ImageImportSource holds source information for ImageImport 190 type ImageImportSource struct { 191 Source io.Reader // Source is the data to send to the server to create this image from (mutually exclusive with SourceName) 192 SourceName string // SourceName is the name of the image to pull (mutually exclusive with Source) 193 } 194 195 // ImageImportOptions holds information to import images from the client host. 196 type ImageImportOptions struct { 197 Tag string // Tag is the name to tag this image with. This attribute is deprecated. 198 Message string // Message is the message to tag the image with 199 Changes []string // Changes are the raw changes to apply to this image 200 } 201 202 // ImageListOptions holds parameters to filter the list of images with. 203 type ImageListOptions struct { 204 MatchName string 205 All bool 206 Filters filters.Args 207 } 208 209 // ImageLoadResponse returns information to the client about a load process. 210 type ImageLoadResponse struct { 211 // Body must be closed to avoid a resource leak 212 Body io.ReadCloser 213 JSON bool 214 } 215 216 // ImagePullOptions holds information to pull images. 217 type ImagePullOptions struct { 218 All bool 219 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 220 PrivilegeFunc RequestPrivilegeFunc 221 } 222 223 // RequestPrivilegeFunc is a function interface that 224 // clients can supply to retry operations after 225 // getting an authorization error. 226 // This function returns the registry authentication 227 // header value in base 64 format, or an error 228 // if the privilege request fails. 229 type RequestPrivilegeFunc func() (string, error) 230 231 //ImagePushOptions holds information to push images. 232 type ImagePushOptions ImagePullOptions 233 234 // ImageRemoveOptions holds parameters to remove images. 235 type ImageRemoveOptions struct { 236 Force bool 237 PruneChildren bool 238 } 239 240 // ImageSearchOptions holds parameters to search images with. 241 type ImageSearchOptions struct { 242 RegistryAuth string 243 PrivilegeFunc RequestPrivilegeFunc 244 Filters filters.Args 245 Limit int 246 } 247 248 // ResizeOptions holds parameters to resize a tty. 249 // It can be used to resize container ttys and 250 // exec process ttys too. 251 type ResizeOptions struct { 252 Height uint 253 Width uint 254 } 255 256 // VersionResponse holds version information for the client and the server 257 type VersionResponse struct { 258 Client *Version 259 Server *Version 260 } 261 262 // ServerOK returns true when the client could connect to the docker server 263 // and parse the information received. It returns false otherwise. 264 func (v VersionResponse) ServerOK() bool { 265 return v.Server != nil 266 } 267 268 // NodeListOptions holds parameters to list nodes with. 269 type NodeListOptions struct { 270 Filter filters.Args 271 } 272 273 // NodeRemoveOptions holds parameters to remove nodes with. 274 type NodeRemoveOptions struct { 275 Force bool 276 } 277 278 // ServiceCreateOptions contains the options to use when creating a service. 279 type ServiceCreateOptions struct { 280 // EncodedRegistryAuth is the encoded registry authorization credentials to 281 // use when updating the service. 282 // 283 // This field follows the format of the X-Registry-Auth header. 284 EncodedRegistryAuth string 285 } 286 287 // ServiceCreateResponse contains the information returned to a client 288 // on the creation of a new service. 289 type ServiceCreateResponse struct { 290 // ID is the ID of the created service. 291 ID string 292 } 293 294 // Values for RegistryAuthFrom in ServiceUpdateOptions 295 const ( 296 RegistryAuthFromSpec = "spec" 297 RegistryAuthFromPreviousSpec = "previous-spec" 298 ) 299 300 // ServiceUpdateOptions contains the options to be used for updating services. 301 type ServiceUpdateOptions struct { 302 // EncodedRegistryAuth is the encoded registry authorization credentials to 303 // use when updating the service. 304 // 305 // This field follows the format of the X-Registry-Auth header. 306 EncodedRegistryAuth string 307 308 // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate 309 // into this field. While it does open API users up to racy writes, most 310 // users may not need that level of consistency in practice. 311 312 // RegistryAuthFrom specifies where to find the registry authorization 313 // credentials if they are not given in EncodedRegistryAuth. Valid 314 // values are "spec" and "previous-spec". 315 RegistryAuthFrom string 316 } 317 318 // ServiceListOptions holds parameters to list services with. 319 type ServiceListOptions struct { 320 Filter filters.Args 321 } 322 323 // TaskListOptions holds parameters to list tasks with. 324 type TaskListOptions struct { 325 Filter filters.Args 326 } 327 328 // PluginRemoveOptions holds parameters to remove plugins. 329 type PluginRemoveOptions struct { 330 Force bool 331 } 332 333 // PluginInstallOptions holds parameters to install a plugin. 334 type PluginInstallOptions struct { 335 Disabled bool 336 AcceptAllPermissions bool 337 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 338 PrivilegeFunc RequestPrivilegeFunc 339 AcceptPermissionsFunc func(PluginPrivileges) (bool, error) 340 }