github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/api/types/types.go (about) 1 package types // import "github.com/Prakhar-Agarwal-byte/moby/api/types" 2 3 import ( 4 "io" 5 "os" 6 "time" 7 8 "github.com/Prakhar-Agarwal-byte/moby/api/types/container" 9 "github.com/Prakhar-Agarwal-byte/moby/api/types/filters" 10 "github.com/Prakhar-Agarwal-byte/moby/api/types/image" 11 "github.com/Prakhar-Agarwal-byte/moby/api/types/mount" 12 "github.com/Prakhar-Agarwal-byte/moby/api/types/network" 13 "github.com/Prakhar-Agarwal-byte/moby/api/types/swarm" 14 "github.com/Prakhar-Agarwal-byte/moby/api/types/volume" 15 "github.com/docker/go-connections/nat" 16 ) 17 18 const ( 19 // MediaTypeRawStream is vendor specific MIME-Type set for raw TTY streams 20 MediaTypeRawStream = "application/vnd.docker.raw-stream" 21 22 // MediaTypeMultiplexedStream is vendor specific MIME-Type set for stdin/stdout/stderr multiplexed streams 23 MediaTypeMultiplexedStream = "application/vnd.docker.multiplexed-stream" 24 ) 25 26 // RootFS returns Image's RootFS description including the layer IDs. 27 type RootFS struct { 28 Type string `json:",omitempty"` 29 Layers []string `json:",omitempty"` 30 } 31 32 // ImageInspect contains response of Engine API: 33 // GET "/images/{name:.*}/json" 34 type ImageInspect struct { 35 // ID is the content-addressable ID of an image. 36 // 37 // This identifier is a content-addressable digest calculated from the 38 // image's configuration (which includes the digests of layers used by 39 // the image). 40 // 41 // Note that this digest differs from the `RepoDigests` below, which 42 // holds digests of image manifests that reference the image. 43 ID string `json:"Id"` 44 45 // RepoTags is a list of image names/tags in the local image cache that 46 // reference this image. 47 // 48 // Multiple image tags can refer to the same image, and this list may be 49 // empty if no tags reference the image, in which case the image is 50 // "untagged", in which case it can still be referenced by its ID. 51 RepoTags []string 52 53 // RepoDigests is a list of content-addressable digests of locally available 54 // image manifests that the image is referenced from. Multiple manifests can 55 // refer to the same image. 56 // 57 // These digests are usually only available if the image was either pulled 58 // from a registry, or if the image was pushed to a registry, which is when 59 // the manifest is generated and its digest calculated. 60 RepoDigests []string 61 62 // Parent is the ID of the parent image. 63 // 64 // Depending on how the image was created, this field may be empty and 65 // is only set for images that were built/created locally. This field 66 // is empty if the image was pulled from an image registry. 67 Parent string 68 69 // Comment is an optional message that can be set when committing or 70 // importing the image. 71 Comment string 72 73 // Created is the date and time at which the image was created, formatted in 74 // RFC 3339 nano-seconds (time.RFC3339Nano). 75 Created string 76 77 // Container is the ID of the container that was used to create the image. 78 // 79 // Depending on how the image was created, this field may be empty. 80 Container string 81 82 // ContainerConfig is an optional field containing the configuration of the 83 // container that was last committed when creating the image. 84 // 85 // Previous versions of Docker builder used this field to store build cache, 86 // and it is not in active use anymore. 87 ContainerConfig *container.Config 88 89 // DockerVersion is the version of Docker that was used to build the image. 90 // 91 // Depending on how the image was created, this field may be empty. 92 DockerVersion string 93 94 // Author is the name of the author that was specified when committing the 95 // image, or as specified through MAINTAINER (deprecated) in the Dockerfile. 96 Author string 97 Config *container.Config 98 99 // Architecture is the hardware CPU architecture that the image runs on. 100 Architecture string 101 102 // Variant is the CPU architecture variant (presently ARM-only). 103 Variant string `json:",omitempty"` 104 105 // OS is the Operating System the image is built to run on. 106 Os string 107 108 // OsVersion is the version of the Operating System the image is built to 109 // run on (especially for Windows). 110 OsVersion string `json:",omitempty"` 111 112 // Size is the total size of the image including all layers it is composed of. 113 Size int64 114 115 // VirtualSize is the total size of the image including all layers it is 116 // composed of. 117 // 118 // Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead. 119 VirtualSize int64 `json:"VirtualSize,omitempty"` 120 121 // GraphDriver holds information about the storage driver used to store the 122 // container's and image's filesystem. 123 GraphDriver GraphDriverData 124 125 // RootFS contains information about the image's RootFS, including the 126 // layer IDs. 127 RootFS RootFS 128 129 // Metadata of the image in the local cache. 130 // 131 // This information is local to the daemon, and not part of the image itself. 132 Metadata image.Metadata 133 } 134 135 // Container contains response of Engine API: 136 // GET "/containers/json" 137 type Container struct { 138 ID string `json:"Id"` 139 Names []string 140 Image string 141 ImageID string 142 Command string 143 Created int64 144 Ports []Port 145 SizeRw int64 `json:",omitempty"` 146 SizeRootFs int64 `json:",omitempty"` 147 Labels map[string]string 148 State string 149 Status string 150 HostConfig struct { 151 NetworkMode string `json:",omitempty"` 152 } 153 NetworkSettings *SummaryNetworkSettings 154 Mounts []MountPoint 155 } 156 157 // CopyConfig contains request body of Engine API: 158 // POST "/containers/"+containerID+"/copy" 159 type CopyConfig struct { 160 Resource string 161 } 162 163 // ContainerPathStat is used to encode the header from 164 // GET "/containers/{name:.*}/archive" 165 // "Name" is the file or directory name. 166 type ContainerPathStat struct { 167 Name string `json:"name"` 168 Size int64 `json:"size"` 169 Mode os.FileMode `json:"mode"` 170 Mtime time.Time `json:"mtime"` 171 LinkTarget string `json:"linkTarget"` 172 } 173 174 // ContainerStats contains response of Engine API: 175 // GET "/stats" 176 type ContainerStats struct { 177 Body io.ReadCloser `json:"body"` 178 OSType string `json:"ostype"` 179 } 180 181 // Ping contains response of Engine API: 182 // GET "/_ping" 183 type Ping struct { 184 APIVersion string 185 OSType string 186 Experimental bool 187 BuilderVersion BuilderVersion 188 189 // SwarmStatus provides information about the current swarm status of the 190 // engine, obtained from the "Swarm" header in the API response. 191 // 192 // It can be a nil struct if the API version does not provide this header 193 // in the ping response, or if an error occurred, in which case the client 194 // should use other ways to get the current swarm status, such as the /swarm 195 // endpoint. 196 SwarmStatus *swarm.Status 197 } 198 199 // ComponentVersion describes the version information for a specific component. 200 type ComponentVersion struct { 201 Name string 202 Version string 203 Details map[string]string `json:",omitempty"` 204 } 205 206 // Version contains response of Engine API: 207 // GET "/version" 208 type Version struct { 209 Platform struct{ Name string } `json:",omitempty"` 210 Components []ComponentVersion `json:",omitempty"` 211 212 // The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility 213 214 Version string 215 APIVersion string `json:"ApiVersion"` 216 MinAPIVersion string `json:"MinAPIVersion,omitempty"` 217 GitCommit string 218 GoVersion string 219 Os string 220 Arch string 221 KernelVersion string `json:",omitempty"` 222 Experimental bool `json:",omitempty"` 223 BuildTime string `json:",omitempty"` 224 } 225 226 // ExecStartCheck is a temp struct used by execStart 227 // Config fields is part of ExecConfig in runconfig package 228 type ExecStartCheck struct { 229 // ExecStart will first check if it's detached 230 Detach bool 231 // Check if there's a tty 232 Tty bool 233 // Terminal size [height, width], unused if Tty == false 234 ConsoleSize *[2]uint `json:",omitempty"` 235 } 236 237 // HealthcheckResult stores information about a single run of a healthcheck probe 238 type HealthcheckResult struct { 239 Start time.Time // Start is the time this check started 240 End time.Time // End is the time this check ended 241 ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe 242 Output string // Output from last check 243 } 244 245 // Health states 246 const ( 247 NoHealthcheck = "none" // Indicates there is no healthcheck 248 Starting = "starting" // Starting indicates that the container is not yet ready 249 Healthy = "healthy" // Healthy indicates that the container is running correctly 250 Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem 251 ) 252 253 // Health stores information about the container's healthcheck results 254 type Health struct { 255 Status string // Status is one of Starting, Healthy or Unhealthy 256 FailingStreak int // FailingStreak is the number of consecutive failures 257 Log []*HealthcheckResult // Log contains the last few results (oldest first) 258 } 259 260 // ContainerState stores container's running state 261 // it's part of ContainerJSONBase and will return by "inspect" command 262 type ContainerState struct { 263 Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead" 264 Running bool 265 Paused bool 266 Restarting bool 267 OOMKilled bool 268 Dead bool 269 Pid int 270 ExitCode int 271 Error string 272 StartedAt string 273 FinishedAt string 274 Health *Health `json:",omitempty"` 275 } 276 277 // ContainerNode stores information about the node that a container 278 // is running on. It's only used by the Docker Swarm standalone API 279 type ContainerNode struct { 280 ID string 281 IPAddress string `json:"IP"` 282 Addr string 283 Name string 284 Cpus int 285 Memory int64 286 Labels map[string]string 287 } 288 289 // ContainerJSONBase contains response of Engine API: 290 // GET "/containers/{name:.*}/json" 291 type ContainerJSONBase struct { 292 ID string `json:"Id"` 293 Created string 294 Path string 295 Args []string 296 State *ContainerState 297 Image string 298 ResolvConfPath string 299 HostnamePath string 300 HostsPath string 301 LogPath string 302 Node *ContainerNode `json:",omitempty"` // Node is only propagated by Docker Swarm standalone API 303 Name string 304 RestartCount int 305 Driver string 306 Platform string 307 MountLabel string 308 ProcessLabel string 309 AppArmorProfile string 310 ExecIDs []string 311 HostConfig *container.HostConfig 312 GraphDriver GraphDriverData 313 SizeRw *int64 `json:",omitempty"` 314 SizeRootFs *int64 `json:",omitempty"` 315 } 316 317 // ContainerJSON is newly used struct along with MountPoint 318 type ContainerJSON struct { 319 *ContainerJSONBase 320 Mounts []MountPoint 321 Config *container.Config 322 NetworkSettings *NetworkSettings 323 } 324 325 // NetworkSettings exposes the network settings in the api 326 type NetworkSettings struct { 327 NetworkSettingsBase 328 DefaultNetworkSettings 329 Networks map[string]*network.EndpointSettings 330 } 331 332 // SummaryNetworkSettings provides a summary of container's networks 333 // in /containers/json 334 type SummaryNetworkSettings struct { 335 Networks map[string]*network.EndpointSettings 336 } 337 338 // NetworkSettingsBase holds basic information about networks 339 type NetworkSettingsBase struct { 340 Bridge string // Bridge is the Bridge name the network uses(e.g. `docker0`) 341 SandboxID string // SandboxID uniquely represents a container's network stack 342 HairpinMode bool // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface 343 LinkLocalIPv6Address string // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix 344 LinkLocalIPv6PrefixLen int // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address 345 Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port 346 SandboxKey string // SandboxKey identifies the sandbox 347 SecondaryIPAddresses []network.Address 348 SecondaryIPv6Addresses []network.Address 349 } 350 351 // DefaultNetworkSettings holds network information 352 // during the 2 release deprecation period. 353 // It will be removed in Docker 1.11. 354 type DefaultNetworkSettings struct { 355 EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox 356 Gateway string // Gateway holds the gateway address for the network 357 GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address 358 GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address 359 IPAddress string // IPAddress holds the IPv4 address for the network 360 IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address 361 IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6 362 MacAddress string // MacAddress holds the MAC address for the network 363 } 364 365 // MountPoint represents a mount point configuration inside the container. 366 // This is used for reporting the mountpoints in use by a container. 367 type MountPoint struct { 368 // Type is the type of mount, see `Type<foo>` definitions in 369 // github.com/Prakhar-Agarwal-byte/moby/api/types/mount.Type 370 Type mount.Type `json:",omitempty"` 371 372 // Name is the name reference to the underlying data defined by `Source` 373 // e.g., the volume name. 374 Name string `json:",omitempty"` 375 376 // Source is the source location of the mount. 377 // 378 // For volumes, this contains the storage location of the volume (within 379 // `/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains 380 // the source (host) part of the bind-mount. For `tmpfs` mount points, this 381 // field is empty. 382 Source string 383 384 // Destination is the path relative to the container root (`/`) where the 385 // Source is mounted inside the container. 386 Destination string 387 388 // Driver is the volume driver used to create the volume (if it is a volume). 389 Driver string `json:",omitempty"` 390 391 // Mode is a comma separated list of options supplied by the user when 392 // creating the bind/volume mount. 393 // 394 // The default is platform-specific (`"z"` on Linux, empty on Windows). 395 Mode string 396 397 // RW indicates whether the mount is mounted writable (read-write). 398 RW bool 399 400 // Propagation describes how mounts are propagated from the host into the 401 // mount point, and vice-versa. Refer to the Linux kernel documentation 402 // for details: 403 // https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt 404 // 405 // This field is not used on Windows. 406 Propagation mount.Propagation 407 } 408 409 // NetworkResource is the body of the "get network" http response message 410 type NetworkResource struct { 411 Name string // Name is the requested name of the network 412 ID string `json:"Id"` // ID uniquely identifies a network on a single machine 413 Created time.Time // Created is the time the network created 414 Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level) 415 Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`) 416 EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6 417 IPAM network.IPAM // IPAM is the network's IP Address Management 418 Internal bool // Internal represents if the network is used internal only 419 Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode. 420 Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster. 421 ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. 422 ConfigOnly bool // ConfigOnly networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services. 423 Containers map[string]EndpointResource // Containers contains endpoints belonging to the network 424 Options map[string]string // Options holds the network specific options to use for when creating the network 425 Labels map[string]string // Labels holds metadata specific to the network being created 426 Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network 427 Services map[string]network.ServiceInfo `json:",omitempty"` 428 } 429 430 // EndpointResource contains network resources allocated and used for a container in a network 431 type EndpointResource struct { 432 Name string 433 EndpointID string 434 MacAddress string 435 IPv4Address string 436 IPv6Address string 437 } 438 439 // NetworkCreate is the expected body of the "create network" http request message 440 type NetworkCreate struct { 441 // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client 442 // package to older daemons. 443 CheckDuplicate bool `json:",omitempty"` 444 Driver string 445 Scope string 446 EnableIPv6 bool 447 IPAM *network.IPAM 448 Internal bool 449 Attachable bool 450 Ingress bool 451 ConfigOnly bool 452 ConfigFrom *network.ConfigReference 453 Options map[string]string 454 Labels map[string]string 455 } 456 457 // NetworkCreateRequest is the request message sent to the server for network create call. 458 type NetworkCreateRequest struct { 459 NetworkCreate 460 Name string 461 } 462 463 // NetworkCreateResponse is the response message sent by the server for network create call 464 type NetworkCreateResponse struct { 465 ID string `json:"Id"` 466 Warning string 467 } 468 469 // NetworkConnect represents the data to be used to connect a container to the network 470 type NetworkConnect struct { 471 Container string 472 EndpointConfig *network.EndpointSettings `json:",omitempty"` 473 } 474 475 // NetworkDisconnect represents the data to be used to disconnect a container from the network 476 type NetworkDisconnect struct { 477 Container string 478 Force bool 479 } 480 481 // NetworkInspectOptions holds parameters to inspect network 482 type NetworkInspectOptions struct { 483 Scope string 484 Verbose bool 485 } 486 487 // DiskUsageObject represents an object type used for disk usage query filtering. 488 type DiskUsageObject string 489 490 const ( 491 // ContainerObject represents a container DiskUsageObject. 492 ContainerObject DiskUsageObject = "container" 493 // ImageObject represents an image DiskUsageObject. 494 ImageObject DiskUsageObject = "image" 495 // VolumeObject represents a volume DiskUsageObject. 496 VolumeObject DiskUsageObject = "volume" 497 // BuildCacheObject represents a build-cache DiskUsageObject. 498 BuildCacheObject DiskUsageObject = "build-cache" 499 ) 500 501 // DiskUsageOptions holds parameters for system disk usage query. 502 type DiskUsageOptions struct { 503 // Types specifies what object types to include in the response. If empty, 504 // all object types are returned. 505 Types []DiskUsageObject 506 } 507 508 // DiskUsage contains response of Engine API: 509 // GET "/system/df" 510 type DiskUsage struct { 511 LayersSize int64 512 Images []*image.Summary 513 Containers []*Container 514 Volumes []*volume.Volume 515 BuildCache []*BuildCache 516 BuilderSize int64 `json:",omitempty"` // Deprecated: deprecated in API 1.38, and no longer used since API 1.40. 517 } 518 519 // ContainersPruneReport contains the response for Engine API: 520 // POST "/containers/prune" 521 type ContainersPruneReport struct { 522 ContainersDeleted []string 523 SpaceReclaimed uint64 524 } 525 526 // VolumesPruneReport contains the response for Engine API: 527 // POST "/volumes/prune" 528 type VolumesPruneReport struct { 529 VolumesDeleted []string 530 SpaceReclaimed uint64 531 } 532 533 // ImagesPruneReport contains the response for Engine API: 534 // POST "/images/prune" 535 type ImagesPruneReport struct { 536 ImagesDeleted []image.DeleteResponse 537 SpaceReclaimed uint64 538 } 539 540 // BuildCachePruneReport contains the response for Engine API: 541 // POST "/build/prune" 542 type BuildCachePruneReport struct { 543 CachesDeleted []string 544 SpaceReclaimed uint64 545 } 546 547 // NetworksPruneReport contains the response for Engine API: 548 // POST "/networks/prune" 549 type NetworksPruneReport struct { 550 NetworksDeleted []string 551 } 552 553 // SecretCreateResponse contains the information returned to a client 554 // on the creation of a new secret. 555 type SecretCreateResponse struct { 556 // ID is the id of the created secret. 557 ID string 558 } 559 560 // SecretListOptions holds parameters to list secrets 561 type SecretListOptions struct { 562 Filters filters.Args 563 } 564 565 // ConfigCreateResponse contains the information returned to a client 566 // on the creation of a new config. 567 type ConfigCreateResponse struct { 568 // ID is the id of the created config. 569 ID string 570 } 571 572 // ConfigListOptions holds parameters to list configs 573 type ConfigListOptions struct { 574 Filters filters.Args 575 } 576 577 // PushResult contains the tag, manifest digest, and manifest size from the 578 // push. It's used to signal this information to the trust code in the client 579 // so it can sign the manifest if necessary. 580 type PushResult struct { 581 Tag string 582 Digest string 583 Size int 584 } 585 586 // BuildResult contains the image id of a successful build 587 type BuildResult struct { 588 ID string 589 } 590 591 // BuildCache contains information about a build cache record. 592 type BuildCache struct { 593 // ID is the unique ID of the build cache record. 594 ID string 595 // Parent is the ID of the parent build cache record. 596 // 597 // Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead. 598 Parent string `json:"Parent,omitempty"` 599 // Parents is the list of parent build cache record IDs. 600 Parents []string `json:" Parents,omitempty"` 601 // Type is the cache record type. 602 Type string 603 // Description is a description of the build-step that produced the build cache. 604 Description string 605 // InUse indicates if the build cache is in use. 606 InUse bool 607 // Shared indicates if the build cache is shared. 608 Shared bool 609 // Size is the amount of disk space used by the build cache (in bytes). 610 Size int64 611 // CreatedAt is the date and time at which the build cache was created. 612 CreatedAt time.Time 613 // LastUsedAt is the date and time at which the build cache was last used. 614 LastUsedAt *time.Time 615 UsageCount int 616 } 617 618 // BuildCachePruneOptions hold parameters to prune the build cache 619 type BuildCachePruneOptions struct { 620 All bool 621 KeepStorage int64 622 Filters filters.Args 623 }