github.com/jfrazelle/docker@v1.1.2-0.20210712172922-bf78e25fe508/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 `json:"ID"` 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 Size bool 63 All bool 64 Latest bool 65 Since string 66 Before string 67 Limit int 68 Filters filters.Args 69 } 70 71 // ContainerLogsOptions holds parameters to filter logs with. 72 type ContainerLogsOptions struct { 73 ShowStdout bool 74 ShowStderr bool 75 Since string 76 Until 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 SessionID string 182 Platform string 183 // Version specifies the version of the unerlying builder to use 184 Version BuilderVersion 185 // BuildID is an optional identifier that can be passed together with the 186 // build request. The same identifier can be used to gracefully cancel the 187 // build with the cancel request. 188 BuildID string 189 // Outputs defines configurations for exporting build results. Only supported 190 // in BuildKit mode 191 Outputs []ImageBuildOutput 192 } 193 194 // ImageBuildOutput defines configuration for exporting a build result 195 type ImageBuildOutput struct { 196 Type string 197 Attrs map[string]string 198 } 199 200 // BuilderVersion sets the version of underlying builder to use 201 type BuilderVersion string 202 203 const ( 204 // BuilderV1 is the first generation builder in docker daemon 205 BuilderV1 BuilderVersion = "1" 206 // BuilderBuildKit is builder based on moby/buildkit project 207 BuilderBuildKit BuilderVersion = "2" 208 ) 209 210 // ImageBuildResponse holds information 211 // returned by a server after building 212 // an image. 213 type ImageBuildResponse struct { 214 Body io.ReadCloser 215 OSType string 216 } 217 218 // ImageCreateOptions holds information to create images. 219 type ImageCreateOptions struct { 220 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry. 221 Platform string // Platform is the target platform of the image if it needs to be pulled from the registry. 222 } 223 224 // ImageImportSource holds source information for ImageImport 225 type ImageImportSource struct { 226 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. 227 SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute. 228 } 229 230 // ImageImportOptions holds information to import images from the client host. 231 type ImageImportOptions struct { 232 Tag string // Tag is the name to tag this image with. This attribute is deprecated. 233 Message string // Message is the message to tag the image with 234 Changes []string // Changes are the raw changes to apply to this image 235 Platform string // Platform is the target platform of the image 236 } 237 238 // ImageListOptions holds parameters to filter the list of images with. 239 type ImageListOptions struct { 240 All bool 241 Filters filters.Args 242 } 243 244 // ImageLoadResponse returns information to the client about a load process. 245 type ImageLoadResponse struct { 246 // Body must be closed to avoid a resource leak 247 Body io.ReadCloser 248 JSON bool 249 } 250 251 // ImagePullOptions holds information to pull images. 252 type ImagePullOptions struct { 253 All bool 254 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 255 PrivilegeFunc RequestPrivilegeFunc 256 Platform string 257 } 258 259 // RequestPrivilegeFunc is a function interface that 260 // clients can supply to retry operations after 261 // getting an authorization error. 262 // This function returns the registry authentication 263 // header value in base 64 format, or an error 264 // if the privilege request fails. 265 type RequestPrivilegeFunc func() (string, error) 266 267 // ImagePushOptions holds information to push images. 268 type ImagePushOptions ImagePullOptions 269 270 // ImageRemoveOptions holds parameters to remove images. 271 type ImageRemoveOptions struct { 272 Force bool 273 PruneChildren bool 274 } 275 276 // ImageSearchOptions holds parameters to search images with. 277 type ImageSearchOptions struct { 278 RegistryAuth string 279 PrivilegeFunc RequestPrivilegeFunc 280 Filters filters.Args 281 Limit int 282 } 283 284 // ResizeOptions holds parameters to resize a tty. 285 // It can be used to resize container ttys and 286 // exec process ttys too. 287 type ResizeOptions struct { 288 Height uint 289 Width uint 290 } 291 292 // NodeListOptions holds parameters to list nodes with. 293 type NodeListOptions struct { 294 Filters filters.Args 295 } 296 297 // NodeRemoveOptions holds parameters to remove nodes with. 298 type NodeRemoveOptions struct { 299 Force bool 300 } 301 302 // ServiceCreateOptions contains the options to use when creating a service. 303 type ServiceCreateOptions 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 // QueryRegistry indicates whether the service update requires 311 // contacting a registry. A registry may be contacted to retrieve 312 // the image digest and manifest, which in turn can be used to update 313 // platform or other information about the service. 314 QueryRegistry bool 315 } 316 317 // ServiceCreateResponse contains the information returned to a client 318 // on the creation of a new service. 319 type ServiceCreateResponse struct { 320 // ID is the ID of the created service. 321 ID string 322 // Warnings is a set of non-fatal warning messages to pass on to the user. 323 Warnings []string `json:",omitempty"` 324 } 325 326 // Values for RegistryAuthFrom in ServiceUpdateOptions 327 const ( 328 RegistryAuthFromSpec = "spec" 329 RegistryAuthFromPreviousSpec = "previous-spec" 330 ) 331 332 // ServiceUpdateOptions contains the options to be used for updating services. 333 type ServiceUpdateOptions struct { 334 // EncodedRegistryAuth is the encoded registry authorization credentials to 335 // use when updating the service. 336 // 337 // This field follows the format of the X-Registry-Auth header. 338 EncodedRegistryAuth string 339 340 // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate 341 // into this field. While it does open API users up to racy writes, most 342 // users may not need that level of consistency in practice. 343 344 // RegistryAuthFrom specifies where to find the registry authorization 345 // credentials if they are not given in EncodedRegistryAuth. Valid 346 // values are "spec" and "previous-spec". 347 RegistryAuthFrom string 348 349 // Rollback indicates whether a server-side rollback should be 350 // performed. When this is set, the provided spec will be ignored. 351 // The valid values are "previous" and "none". An empty value is the 352 // same as "none". 353 Rollback string 354 355 // QueryRegistry indicates whether the service update requires 356 // contacting a registry. A registry may be contacted to retrieve 357 // the image digest and manifest, which in turn can be used to update 358 // platform or other information about the service. 359 QueryRegistry bool 360 } 361 362 // ServiceListOptions holds parameters to list services with. 363 type ServiceListOptions struct { 364 Filters filters.Args 365 366 // Status indicates whether the server should include the service task 367 // count of running and desired tasks. 368 Status bool 369 } 370 371 // ServiceInspectOptions holds parameters related to the "service inspect" 372 // operation. 373 type ServiceInspectOptions struct { 374 InsertDefaults bool 375 } 376 377 // TaskListOptions holds parameters to list tasks with. 378 type TaskListOptions struct { 379 Filters filters.Args 380 } 381 382 // PluginRemoveOptions holds parameters to remove plugins. 383 type PluginRemoveOptions struct { 384 Force bool 385 } 386 387 // PluginEnableOptions holds parameters to enable plugins. 388 type PluginEnableOptions struct { 389 Timeout int 390 } 391 392 // PluginDisableOptions holds parameters to disable plugins. 393 type PluginDisableOptions struct { 394 Force bool 395 } 396 397 // PluginInstallOptions holds parameters to install a plugin. 398 type PluginInstallOptions struct { 399 Disabled bool 400 AcceptAllPermissions bool 401 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 402 RemoteRef string // RemoteRef is the plugin name on the registry 403 PrivilegeFunc RequestPrivilegeFunc 404 AcceptPermissionsFunc func(PluginPrivileges) (bool, error) 405 Args []string 406 } 407 408 // SwarmUnlockKeyResponse contains the response for Engine API: 409 // GET /swarm/unlockkey 410 type SwarmUnlockKeyResponse struct { 411 // UnlockKey is the unlock key in ASCII-armored format. 412 UnlockKey string 413 } 414 415 // PluginCreateOptions hold all options to plugin create. 416 type PluginCreateOptions struct { 417 RepoName string 418 }