|
| 1 | +package windowsoci |
| 2 | + |
| 3 | +// This file is a hack - essentially a mirror of OCI spec for Windows. |
| 4 | + |
| 5 | +import ( |
| 6 | + "fmt" |
| 7 | + |
| 8 | + "github.com/docker/go-connections/nat" |
| 9 | +) |
| 10 | + |
| 11 | +// WindowsSpec is the full specification for Windows containers. |
| 12 | +type WindowsSpec struct { |
| 13 | + Spec |
| 14 | + |
| 15 | + // Windows is platform specific configuration for Windows based containers. |
| 16 | + Windows Windows `json:"windows"` |
| 17 | +} |
| 18 | + |
| 19 | +// Spec is the base configuration for the container. It specifies platform |
| 20 | +// independent configuration. This information must be included when the |
| 21 | +// bundle is packaged for distribution. |
| 22 | +type Spec struct { |
| 23 | + |
| 24 | + // Version is the version of the specification that is supported. |
| 25 | + Version string `json:"ociVersion"` |
| 26 | + // Platform is the host information for OS and Arch. |
| 27 | + Platform Platform `json:"platform"` |
| 28 | + // Process is the container's main process. |
| 29 | + Process Process `json:"process"` |
| 30 | + // Root is the root information for the container's filesystem. |
| 31 | + Root Root `json:"root"` |
| 32 | + // Hostname is the container's host name. |
| 33 | + Hostname string `json:"hostname,omitempty"` |
| 34 | + // Mounts profile configuration for adding mounts to the container's filesystem. |
| 35 | + Mounts []Mount `json:"mounts"` |
| 36 | +} |
| 37 | + |
| 38 | +// Windows contains platform specific configuration for Windows based containers. |
| 39 | +type Windows struct { |
| 40 | + // Resources contain information for handling resource constraints for the container |
| 41 | + Resources *Resources `json:"resources,omitempty"` |
| 42 | + // Networking contains the platform specific network settings for the container. |
| 43 | + Networking *Networking `json:"networking,omitempty"` |
| 44 | + // FirstStart is used for an optimization on first boot of Windows |
| 45 | + FirstStart bool `json:"first_start,omitempty"` |
| 46 | + // LayerFolder is the path to the current layer folder |
| 47 | + LayerFolder string `json:"layer_folder,omitempty"` |
| 48 | + // Layer paths of the parent layers |
| 49 | + LayerPaths []string `json:"layer_paths,omitempty"` |
| 50 | + // HvRuntime contains settings specific to Hyper-V containers, omitted if not using Hyper-V isolation |
| 51 | + HvRuntime *HvRuntime `json:"hv_runtime,omitempty"` |
| 52 | +} |
| 53 | + |
| 54 | +// Process contains information to start a specific application inside the container. |
| 55 | +type Process struct { |
| 56 | + // Terminal indicates if stderr should NOT be attached for the container. |
| 57 | + Terminal bool `json:"terminal"` |
| 58 | + // ConsoleSize contains the initial h,w of the console size |
| 59 | + InitialConsoleSize [2]int `json:"-"` |
| 60 | + // User specifies user information for the process. |
| 61 | + User User `json:"user"` |
| 62 | + // Args specifies the binary and arguments for the application to execute. |
| 63 | + Args []string `json:"args"` |
| 64 | + // Env populates the process environment for the process. |
| 65 | + Env []string `json:"env,omitempty"` |
| 66 | + // Cwd is the current working directory for the process and must be |
| 67 | + // relative to the container's root. |
| 68 | + Cwd string `json:"cwd"` |
| 69 | +} |
| 70 | + |
| 71 | +// User contains the user information for Windows |
| 72 | +type User struct { |
| 73 | + User string `json:"user,omitempty"` |
| 74 | +} |
| 75 | + |
| 76 | +// Root contains information about the container's root filesystem on the host. |
| 77 | +type Root struct { |
| 78 | + // Path is the absolute path to the container's root filesystem. |
| 79 | + Path string `json:"path"` |
| 80 | + // Readonly makes the root filesystem for the container readonly before the process is executed. |
| 81 | + Readonly bool `json:"readonly"` |
| 82 | +} |
| 83 | + |
| 84 | +// Platform specifies OS and arch information for the host system that the container |
| 85 | +// is created for. |
| 86 | +type Platform struct { |
| 87 | + // OS is the operating system. |
| 88 | + OS string `json:"os"` |
| 89 | + // Arch is the architecture |
| 90 | + Arch string `json:"arch"` |
| 91 | +} |
| 92 | + |
| 93 | +// Mount specifies a mount for a container. |
| 94 | +type Mount struct { |
| 95 | + // Destination is the path where the mount will be placed relative to the container's root. The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point. |
| 96 | + Destination string `json:"destination"` |
| 97 | + // Type specifies the mount kind. |
| 98 | + Type string `json:"type"` |
| 99 | + // Source specifies the source path of the mount. In the case of bind mounts |
| 100 | + // this would be the file on the host. |
| 101 | + Source string `json:"source"` |
| 102 | + // Readonly specifies if the mount should be read-only |
| 103 | + Readonly bool `json:"readonly"` |
| 104 | +} |
| 105 | + |
| 106 | +// HvRuntime contains settings specific to Hyper-V containers |
| 107 | +type HvRuntime struct { |
| 108 | + // ImagePath is the path to the Utility VM image for this container |
| 109 | + ImagePath string `json:"image_path,omitempty"` |
| 110 | +} |
| 111 | + |
| 112 | +// Networking contains the platform specific network settings for the container |
| 113 | +type Networking struct { |
| 114 | + // TODO Windows TP5. The following three fields are for 'legacy' non- |
| 115 | + // libnetwork networking through HCS. They can be removed once TP4 is |
| 116 | + // no longer supported. Also remove in libcontainerd\client_windows.go, |
| 117 | + // function Create(), and in daemon\oci_windows.go, function CreateSpec() |
| 118 | + MacAddress string `json:"mac,omitempty"` |
| 119 | + Bridge string `json:"bridge,omitempty"` |
| 120 | + PortBindings nat.PortMap `json:"port_bindings,omitempty"` |
| 121 | + // End of TODO Windows TP5. |
| 122 | + |
| 123 | + // List of endpoints to be attached to the container |
| 124 | + EndpointList []string `json:"endpoints,omitempty"` |
| 125 | +} |
| 126 | + |
| 127 | +// Storage contains storage resource management settings |
| 128 | +type Storage struct { |
| 129 | + // Specifies maximum Iops for the system drive |
| 130 | + Iops *uint64 `json:"iops,omitempty"` |
| 131 | + // Specifies maximum bytes per second for the system drive |
| 132 | + Bps *uint64 `json:"bps,omitempty"` |
| 133 | + // Sandbox size indicates the size to expand the system drive to if it is currently smaller |
| 134 | + SandboxSize *uint64 `json:"sandbox_size,omitempty"` |
| 135 | +} |
| 136 | + |
| 137 | +// Memory contains memory settings for the container |
| 138 | +type Memory struct { |
| 139 | + // Memory limit (in bytes). |
| 140 | + Limit *int64 `json:"limit,omitempty"` |
| 141 | + // Memory reservation (in bytes). |
| 142 | + Reservation *uint64 `json:"reservation,omitempty"` |
| 143 | +} |
| 144 | + |
| 145 | +// CPU contains information for cpu resource management |
| 146 | +type CPU struct { |
| 147 | + // Number of CPUs available to the container. This is an appoximation for Windows Server Containers. |
| 148 | + Count *uint64 `json:"count,omitempty"` |
| 149 | + // CPU shares (relative weight (ratio) vs. other containers with cpu shares). Range is from 1 to 10000. |
| 150 | + Shares *uint64 `json:"shares,omitempty"` |
| 151 | + // Percent of available CPUs usable by the container. |
| 152 | + Percent *int64 `json:"percent,omitempty"` |
| 153 | +} |
| 154 | + |
| 155 | +// Network network resource management information |
| 156 | +type Network struct { |
| 157 | + // Bandwidth is the maximum egress bandwidth in bytes per second |
| 158 | + Bandwidth *uint64 `json:"bandwidth,omitempty"` |
| 159 | +} |
| 160 | + |
| 161 | +// Resources has container runtime resource constraints |
| 162 | +// TODO Windows containerd. This structure needs ratifying with the old resources |
| 163 | +// structure used on Windows and the latest OCI spec. |
| 164 | +type Resources struct { |
| 165 | + // Memory restriction configuration |
| 166 | + Memory *Memory `json:"memory,omitempty"` |
| 167 | + // CPU resource restriction configuration |
| 168 | + CPU *CPU `json:"cpu,omitempty"` |
| 169 | + // Storage restriction configuration |
| 170 | + Storage *Storage `json:"storage,omitempty"` |
| 171 | + // Network restriction configuration |
| 172 | + Network *Network `json:"network,omitempty"` |
| 173 | +} |
| 174 | + |
| 175 | +const ( |
| 176 | + // VersionMajor is for an API incompatible changes |
| 177 | + VersionMajor = 0 |
| 178 | + // VersionMinor is for functionality in a backwards-compatible manner |
| 179 | + VersionMinor = 3 |
| 180 | + // VersionPatch is for backwards-compatible bug fixes |
| 181 | + VersionPatch = 0 |
| 182 | + |
| 183 | + // VersionDev indicates development branch. Releases will be empty string. |
| 184 | + VersionDev = "" |
| 185 | +) |
| 186 | + |
| 187 | +// Version is the specification version that the package types support. |
| 188 | +var Version = fmt.Sprintf("%d.%d.%d%s (Windows)", VersionMajor, VersionMinor, VersionPatch, VersionDev) |
0 commit comments