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