github.com/jiasir/docker@v1.3.3-0.20170609024000-252e610103e7/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 Filters 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 CopyUIDGID bool 101 } 102 103 // EventsOptions holds parameters to filter events with. 104 type EventsOptions struct { 105 Since string 106 Until string 107 Filters filters.Args 108 } 109 110 // NetworkListOptions holds parameters to filter the list of networks with. 111 type NetworkListOptions struct { 112 Filters filters.Args 113 } 114 115 // HijackedResponse holds connection information for a hijacked request. 116 type HijackedResponse struct { 117 Conn net.Conn 118 Reader *bufio.Reader 119 } 120 121 // Close closes the hijacked connection and reader. 122 func (h *HijackedResponse) Close() { 123 h.Conn.Close() 124 } 125 126 // CloseWriter is an interface that implements structs 127 // that close input streams to prevent from writing. 128 type CloseWriter interface { 129 CloseWrite() error 130 } 131 132 // CloseWrite closes a readWriter for writing. 133 func (h *HijackedResponse) CloseWrite() error { 134 if conn, ok := h.Conn.(CloseWriter); ok { 135 return conn.CloseWrite() 136 } 137 return nil 138 } 139 140 // ImageBuildOptions holds the information 141 // necessary to build images. 142 type ImageBuildOptions struct { 143 Tags []string 144 SuppressOutput bool 145 RemoteContext string 146 NoCache bool 147 Remove bool 148 ForceRemove bool 149 PullParent bool 150 Isolation container.Isolation 151 CPUSetCPUs string 152 CPUSetMems string 153 CPUShares int64 154 CPUQuota int64 155 CPUPeriod int64 156 Memory int64 157 MemorySwap int64 158 CgroupParent string 159 NetworkMode string 160 ShmSize int64 161 Dockerfile string 162 Ulimits []*units.Ulimit 163 // BuildArgs needs to be a *string instead of just a string so that 164 // we can tell the difference between "" (empty string) and no value 165 // at all (nil). See the parsing of buildArgs in 166 // api/server/router/build/build_routes.go for even more info. 167 BuildArgs map[string]*string 168 AuthConfigs map[string]AuthConfig 169 Context io.Reader 170 Labels map[string]string 171 // squash the resulting image's layers to the parent 172 // preserves the original image and creates a new one from the parent with all 173 // the changes applied to a single layer 174 Squash bool 175 // CacheFrom specifies images that are used for matching cache. Images 176 // specified here do not need to have a valid parent chain to match cache. 177 CacheFrom []string 178 SecurityOpt []string 179 ExtraHosts []string // List of extra hosts 180 Target string 181 } 182 183 // ImageBuildResponse holds information 184 // returned by a server after building 185 // an image. 186 type ImageBuildResponse struct { 187 Body io.ReadCloser 188 OSType string 189 } 190 191 // ImageCreateOptions holds information to create images. 192 type ImageCreateOptions struct { 193 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 194 } 195 196 // ImageImportSource holds source information for ImageImport 197 type ImageImportSource struct { 198 Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this. 199 SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute. 200 } 201 202 // ImageImportOptions holds information to import images from the client host. 203 type ImageImportOptions struct { 204 Tag string // Tag is the name to tag this image with. This attribute is deprecated. 205 Message string // Message is the message to tag the image with 206 Changes []string // Changes are the raw changes to apply to this image 207 } 208 209 // ImageListOptions holds parameters to filter the list of images with. 210 type ImageListOptions struct { 211 All bool 212 Filters filters.Args 213 } 214 215 // ImageLoadResponse returns information to the client about a load process. 216 type ImageLoadResponse struct { 217 // Body must be closed to avoid a resource leak 218 Body io.ReadCloser 219 JSON bool 220 } 221 222 // ImagePullOptions holds information to pull images. 223 type ImagePullOptions struct { 224 All bool 225 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 226 PrivilegeFunc RequestPrivilegeFunc 227 } 228 229 // RequestPrivilegeFunc is a function interface that 230 // clients can supply to retry operations after 231 // getting an authorization error. 232 // This function returns the registry authentication 233 // header value in base 64 format, or an error 234 // if the privilege request fails. 235 type RequestPrivilegeFunc func() (string, error) 236 237 //ImagePushOptions holds information to push images. 238 type ImagePushOptions ImagePullOptions 239 240 // ImageRemoveOptions holds parameters to remove images. 241 type ImageRemoveOptions struct { 242 Force bool 243 PruneChildren bool 244 } 245 246 // ImageSearchOptions holds parameters to search images with. 247 type ImageSearchOptions struct { 248 RegistryAuth string 249 PrivilegeFunc RequestPrivilegeFunc 250 Filters filters.Args 251 Limit int 252 } 253 254 // ResizeOptions holds parameters to resize a tty. 255 // It can be used to resize container ttys and 256 // exec process ttys too. 257 type ResizeOptions struct { 258 Height uint 259 Width uint 260 } 261 262 // NodeListOptions holds parameters to list nodes with. 263 type NodeListOptions struct { 264 Filters filters.Args 265 } 266 267 // NodeRemoveOptions holds parameters to remove nodes with. 268 type NodeRemoveOptions struct { 269 Force bool 270 } 271 272 // ServiceCreateOptions contains the options to use when creating a service. 273 type ServiceCreateOptions struct { 274 // EncodedRegistryAuth is the encoded registry authorization credentials to 275 // use when updating the service. 276 // 277 // This field follows the format of the X-Registry-Auth header. 278 EncodedRegistryAuth string 279 280 // QueryRegistry indicates whether the service update requires 281 // contacting a registry. A registry may be contacted to retrieve 282 // the image digest and manifest, which in turn can be used to update 283 // platform or other information about the service. 284 QueryRegistry bool 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 // Warnings is a set of non-fatal warning messages to pass on to the user. 293 Warnings []string `json:",omitempty"` 294 } 295 296 // Values for RegistryAuthFrom in ServiceUpdateOptions 297 const ( 298 RegistryAuthFromSpec = "spec" 299 RegistryAuthFromPreviousSpec = "previous-spec" 300 ) 301 302 // ServiceUpdateOptions contains the options to be used for updating services. 303 type ServiceUpdateOptions struct { 304 // EncodedRegistryAuth is the encoded registry authorization credentials to 305 // use when updating the service. 306 // 307 // This field follows the format of the X-Registry-Auth header. 308 EncodedRegistryAuth string 309 310 // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate 311 // into this field. While it does open API users up to racy writes, most 312 // users may not need that level of consistency in practice. 313 314 // RegistryAuthFrom specifies where to find the registry authorization 315 // credentials if they are not given in EncodedRegistryAuth. Valid 316 // values are "spec" and "previous-spec". 317 RegistryAuthFrom string 318 319 // Rollback indicates whether a server-side rollback should be 320 // performed. When this is set, the provided spec will be ignored. 321 // The valid values are "previous" and "none". An empty value is the 322 // same as "none". 323 Rollback string 324 325 // QueryRegistry indicates whether the service update requires 326 // contacting a registry. A registry may be contacted to retrieve 327 // the image digest and manifest, which in turn can be used to update 328 // platform or other information about the service. 329 QueryRegistry bool 330 } 331 332 // ServiceListOptions holds parameters to list services with. 333 type ServiceListOptions struct { 334 Filters filters.Args 335 } 336 337 // ServiceInspectOptions holds parameters related to the "service inspect" 338 // operation. 339 type ServiceInspectOptions struct { 340 InsertDefaults bool 341 } 342 343 // TaskListOptions holds parameters to list tasks with. 344 type TaskListOptions struct { 345 Filters filters.Args 346 } 347 348 // PluginRemoveOptions holds parameters to remove plugins. 349 type PluginRemoveOptions struct { 350 Force bool 351 } 352 353 // PluginEnableOptions holds parameters to enable plugins. 354 type PluginEnableOptions struct { 355 Timeout int 356 } 357 358 // PluginDisableOptions holds parameters to disable plugins. 359 type PluginDisableOptions struct { 360 Force bool 361 } 362 363 // PluginInstallOptions holds parameters to install a plugin. 364 type PluginInstallOptions struct { 365 Disabled bool 366 AcceptAllPermissions bool 367 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 368 RemoteRef string // RemoteRef is the plugin name on the registry 369 PrivilegeFunc RequestPrivilegeFunc 370 AcceptPermissionsFunc func(PluginPrivileges) (bool, error) 371 Args []string 372 } 373 374 // SwarmUnlockKeyResponse contains the response for Engine API: 375 // GET /swarm/unlockkey 376 type SwarmUnlockKeyResponse struct { 377 // UnlockKey is the unlock key in ASCII-armored format. 378 UnlockKey string 379 } 380 381 // PluginCreateOptions hold all options to plugin create. 382 type PluginCreateOptions struct { 383 RepoName string 384 }