Skip to content

Commit 1f4e4ab

Browse files
John HowardJohn Howard
authored andcommitted
Add Windows fields
Signed-off-by: John Howard <[email protected]>
1 parent c8fac66 commit 1f4e4ab

File tree

1 file changed

+98
-14
lines changed

1 file changed

+98
-14
lines changed

specs-go/config.go

Lines changed: 98 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type Spec struct {
2525
Linux Linux `json:"linux" platform:"linux,omitempty"`
2626
// Solaris is platform specific configuration for Solaris containers.
2727
Solaris Solaris `json:"solaris" platform:"solaris,omitempty"`
28+
// Windows is the platform specific configuration for Windows based containers.
29+
Windows Windows `json:"windows" platform:"windows,omitempty"`
2830
}
2931

3032
// Process contains information to start a specific application inside the container.
@@ -51,17 +53,21 @@ type Process struct {
5153
ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"`
5254
// SelinuxLabel specifies the selinux context that the container process is run as. (this field is platform dependent)
5355
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
56+
57+
// InitialConsoleSize specifies the initial [h,w] of the console. (this field is platform dependent)
58+
InitialConsoleSize [2]int `json:"initialConsoleSize,omitempty" platform:"windows"`
5459
}
5560

56-
// User specifies Linux/Solaris specific user and group information for the container's
57-
// main process.
61+
// User specifies the user information for the container
5862
type User struct {
5963
// UID is the user id. (this field is platform dependent)
6064
UID uint32 `json:"uid" platform:"linux,solaris"`
6165
// GID is the group id. (this field is platform dependent)
6266
GID uint32 `json:"gid" platform:"linux,solaris"`
6367
// AdditionalGids are additional group ids set for the container's process. (this field is platform dependent)
6468
AdditionalGids []uint32 `json:"additionalGids,omitempty" platform:"linux,solaris"`
69+
// User is the user name. (this field is platform dependent)
70+
User string `json:"user" platform:"windows"`
6571
}
6672

6773
// Root contains information about the container's root filesystem on the host.
@@ -79,6 +85,8 @@ type Platform struct {
7985
OS string `json:"os"`
8086
// Arch is the architecture
8187
Arch string `json:"arch"`
88+
// OSVersion is the version of the operating system. (this field is platform dependent)
89+
OSVersion string `json:"os.version,omitempty" platform:"windows"`
8290
}
8391

8492
// Mount specifies a mount for a container.
@@ -90,8 +98,10 @@ type Mount struct {
9098
// Source specifies the source path of the mount. In the case of bind mounts on
9199
// Linux based systems this would be the file on the host.
92100
Source string `json:"source"`
93-
// Options are fstab style mount options.
94-
Options []string `json:"options,omitempty"`
101+
// Options are fstab style mount options. (this field is platform dependent)
102+
Options []string `json:"options,omitempty" platform:"linux,solaris"`
103+
// Readonly specifies if the mount should be read-only. (this field is platform dependent)
104+
Readonly bool `json:"readonly" platform:"windows"`
95105
}
96106

97107
// Hook specifies a command that is run at a particular event in the lifecycle of a container
@@ -123,7 +133,7 @@ type Linux struct {
123133
Sysctl map[string]string `json:"sysctl,omitempty"`
124134
// Resources contain cgroup information for handling resource constraints
125135
// for the container
126-
Resources *Resources `json:"resources,omitempty"`
136+
Resources *LinuxResources `json:"resources,omitempty"`
127137
// CgroupsPath specifies the path to cgroups that are created and/or joined by the container.
128138
// The path is expected to be relative to the cgroups mountpoint.
129139
// If resources are specified, the cgroups at CgroupsPath will be updated based on resources.
@@ -252,7 +262,7 @@ type BlockIO struct {
252262
}
253263

254264
// Memory for Linux cgroup 'memory' resource management
255-
type Memory struct {
265+
type LinuxMemory struct {
256266
// Memory limit (in bytes).
257267
Limit *uint64 `json:"limit,omitempty"`
258268
// Memory reservation or soft_limit (in bytes).
@@ -268,7 +278,7 @@ type Memory struct {
268278
}
269279

270280
// CPU for Linux cgroup 'cpu' resource management
271-
type CPU struct {
281+
type LinuxCPU struct {
272282
// CPU shares (relative weight (ratio) vs. other cgroups with cpu shares).
273283
Shares *uint64 `json:"shares,omitempty"`
274284
// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
@@ -291,34 +301,34 @@ type Pids struct {
291301
Limit *int64 `json:"limit,omitempty"`
292302
}
293303

294-
// Network identification and priority configuration
295-
type Network struct {
304+
// LinuxNetwork identification and priority configuration
305+
type LinuxNetwork struct {
296306
// Set class identifier for container's network packets
297307
ClassID *uint32 `json:"classID"`
298308
// Set priority of network traffic for container
299309
Priorities []InterfacePriority `json:"priorities,omitempty"`
300310
}
301311

302-
// Resources has container runtime resource constraints
303-
type Resources struct {
312+
// LinuxResources has container runtime resource constraints for Linux based containers
313+
type LinuxResources struct {
304314
// Devices are a list of device rules for the whitelist controller
305315
Devices []DeviceCgroup `json:"devices"`
306316
// DisableOOMKiller disables the OOM killer for out of memory conditions
307317
DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
308318
// Specify an oom_score_adj for the container.
309319
OOMScoreAdj *int `json:"oomScoreAdj,omitempty"`
310320
// Memory restriction configuration
311-
Memory *Memory `json:"memory,omitempty"`
321+
Memory *LinuxMemory `json:"memory,omitempty"`
312322
// CPU resource restriction configuration
313-
CPU *CPU `json:"cpu,omitempty"`
323+
CPU *LinuxCPU `json:"cpu,omitempty"`
314324
// Task resource restriction configuration.
315325
Pids *Pids `json:"pids,omitempty"`
316326
// BlockIO restriction configuration
317327
BlockIO *BlockIO `json:"blockIO,omitempty"`
318328
// Hugetlb limit (in bytes)
319329
HugepageLimits []HugepageLimit `json:"hugepageLimits,omitempty"`
320330
// Network restriction configuration
321-
Network *Network `json:"network,omitempty"`
331+
Network *LinuxNetwork `json:"network,omitempty"`
322332
}
323333

324334
// Device represents the mknod information for a Linux special device file
@@ -469,3 +479,77 @@ type Syscall struct {
469479
Action Action `json:"action"`
470480
Args []Arg `json:"args,omitempty"`
471481
}
482+
483+
// Windows contains platform specific configuration for Windows based containers.
484+
type Windows struct {
485+
// Resources contains constraints for containers.
486+
Resources *WindowsResources `json:"resources,omitempty"`
487+
// Networking contains the network connection settings for containers.
488+
Networking *Networking `json:"networking,omitempty"`
489+
// FirstStart is an optimization on first boot of a container.
490+
FirstStart bool `json:"first_start,omitempty"`
491+
// LayerFolder is the path to the current layer folder.
492+
LayerFolder string `json:"layer_folder,omitempty"`
493+
// Layer contains the filepaths of the parent layers.
494+
LayerPaths []string `json:"layer_paths,omitempty"`
495+
// Settings relating to Hyper-V containers, omitted otherwise.
496+
HvRuntime *HvRuntime `json:"hv_runtime,omitempty"`
497+
}
498+
499+
// WindowsResources has container runtime resource constraints for Windows based containers.
500+
type WindowsResources struct {
501+
// Network resource configuration.
502+
Network *WindowsNetwork `json:"network,omitempty"`
503+
// Memory resource configuration.
504+
Memory *WindowsMemory `json:"memory,omitempty"`
505+
// CPU resource configuration.
506+
CPU *WindowsCPU `json:"cpu,omitempty"`
507+
// Storage resource configuration.
508+
Storage *WindowsStorage `json:"storage,omitempty"`
509+
}
510+
511+
// WindowsNetwork has network runtime resource constraings for Windows based containers.
512+
type WindowsNetwork struct {
513+
// Bandwidth is the maximum egress bandwidth in bytes per second.
514+
Bandwidth *uint64 `json:"bandwidth,omitempty"`
515+
}
516+
517+
// WindowsMemory has memory runtime resource constraints for Windows based containers.
518+
type WindowsMemory struct {
519+
// Memory limit (in bytes).
520+
Limit *int64 `json:"limit,omitempty"`
521+
// Memory reservation (in bytes).
522+
Reservation *uint64 `json:"reservation,omitempty"`
523+
}
524+
525+
// WindowsCPU has CPU runtime resource constraints for Windows based containers.
526+
type WindowsCPU struct {
527+
// Number of CPUs available to the container. This is an approximation for Windows Server Containers.
528+
Count *uint64 `json:"count,omitempty"`
529+
// CPU shares (relative weight (ratio) vs. other containers with cpu shares). Range is from 1 to 10000.
530+
Shares *uint64 `json:"shares,omitempty"`
531+
// Percent of available CPUs usable by the container.
532+
Percent *int64 `json:"percent,omitempty"`
533+
}
534+
535+
// WindowsStorage has storage resource constraints for Windows based containers.
536+
type WindowsStorage struct {
537+
// Specifies maximum Iops for the system drive.
538+
Iops *uint64 `json:"iops,omitempty"`
539+
// Specifies maximum bytes per second for the system drive.
540+
Bps *uint64 `json:"bps,omitempty"`
541+
// Sandbox size indicates the size to expand the system drive to if it is currently smaller.
542+
SandboxSize *uint64 `json:"sandbox_size,omitempty"`
543+
}
544+
545+
// Networking contains the network configuration for Windows based containers.
546+
type Networking struct {
547+
// List of endpoints to be attached to the container.
548+
EndpointList []string `json:"endpoints,omitempty"`
549+
}
550+
551+
// HvRuntime contains the configuration for Windows based Hyper-V containers.
552+
type HvRuntime struct {
553+
// ImagePath is the path to the Utility VM image.
554+
ImagePath string `json:"image_path,omitempty"`
555+
}

0 commit comments

Comments
 (0)