Skip to content

Commit 9144f82

Browse files
author
Zhou Hao
committed
generate: add windows-servicing option
Signed-off-by: Zhou Hao <[email protected]>
1 parent ef277d6 commit 9144f82

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

cmd/oci-runtime-tool/generate.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ var generateFlags = []cli.Flag{
129129
cli.StringFlag{Name: "windows-resources-cpu", Usage: "specifies CPU for container"},
130130
cli.Uint64Flag{Name: "windows-resources-memory-limit", Usage: "specifies limit of memory"},
131131
cli.StringFlag{Name: "windows-resources-storage", Usage: "specifies storage for container"},
132+
cli.BoolFlag{Name: "windows-servicing", Usage: "servicing operations"},
132133
}
133134

134135
var generateCommand = cli.Command{
@@ -843,18 +844,20 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
843844

844845
if context.IsSet("windows-network") {
845846
network := context.String("windows-network")
846-
err := g.SetWindowsNetwork(network)
847-
if err != nil {
847+
tmpNetwork := rspec.WindowsNetwork{}
848+
if err := json.Unmarshal([]byte(network), &tmpNetwork); err != nil {
848849
return err
849850
}
851+
g.SetWindowsNetwork(tmpNetwork)
850852
}
851853

852854
if context.IsSet("windows-resources-cpu") {
853855
cpu := context.String("windows-resources-cpu")
854-
err := g.SetWindowsResourcesCPU(cpu)
855-
if err != nil {
856+
tmpCPU := rspec.WindowsCPUResources{}
857+
if err := json.Unmarshal([]byte(cpu), &tmpCPU); err != nil {
856858
return err
857859
}
860+
g.SetWindowsResourcesCPU(tmpCPU)
858861
}
859862

860863
if context.IsSet("windows-resources-memory-limit") {
@@ -864,10 +867,15 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
864867

865868
if context.IsSet("windows-resources-storage") {
866869
storage := context.String("windows-resources-storage")
867-
err := g.SetWindowsResourcesStorage(storage)
868-
if err != nil {
870+
tmpStorage := rspec.WindowsStorageResources{}
871+
if err := json.Unmarshal([]byte(storage), &tmpStorage); err != nil {
869872
return err
870873
}
874+
g.SetWindowsResourcesStorage(tmpStorage)
875+
}
876+
877+
if context.IsSet("windows-servicing") {
878+
g.SetWinodwsServicing(context.Bool("windows-servicing"))
871879
}
872880

873881
err := addSeccomp(context, g)

completions/bash/oci-runtime-tool

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ _oci-runtime-tool_generate() {
417417
--process-terminal
418418
--rootfs-readonly
419419
--windows-ignore-flushes-during-boot
420+
--windows-servicing
420421
"
421422

422423
local all_options="$options_with_args $boolean_options"

generate/generate.go

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,27 +1510,15 @@ func (g *Generator) AddWindowsLayerFolders(folder string) {
15101510
}
15111511

15121512
// SetWindowsNetwork sets g.spec.Windows.Network.
1513-
func (g *Generator) SetWindowsNetwork(network string) error {
1513+
func (g *Generator) SetWindowsNetwork(network rspec.WindowsNetwork) {
15141514
g.initSpecWindows()
1515-
tmpNetwork := &rspec.WindowsNetwork{}
1516-
err := json.Unmarshal([]byte(network), tmpNetwork)
1517-
if err != nil {
1518-
return err
1519-
}
1520-
g.spec.Windows.Network = tmpNetwork
1521-
return nil
1515+
g.spec.Windows.Network = &network
15221516
}
15231517

15241518
// SetWindowsResourcesCPU sets g.spec.Windows.Resources.CPU.
1525-
func (g *Generator) SetWindowsResourcesCPU(cpu string) error {
1519+
func (g *Generator) SetWindowsResourcesCPU(cpu rspec.WindowsCPUResources) {
15261520
g.initSpecWindowsResources()
1527-
tmpCPU := &rspec.WindowsCPUResources{}
1528-
err := json.Unmarshal([]byte(cpu), tmpCPU)
1529-
if err != nil {
1530-
return err
1531-
}
1532-
g.spec.Windows.Resources.CPU = tmpCPU
1533-
return nil
1521+
g.spec.Windows.Resources.CPU = &cpu
15341522
}
15351523

15361524
// SetWindowsResourcesMemoryLimit sets g.spec.Windows.Resources.Memory.Limit.
@@ -1540,13 +1528,13 @@ func (g *Generator) SetWindowsResourcesMemoryLimit(limit uint64) {
15401528
}
15411529

15421530
// SetWindowsResourcesStorage sets g.spec.Windows.Resources.Storage.
1543-
func (g *Generator) SetWindowsResourcesStorage(storage string) error {
1531+
func (g *Generator) SetWindowsResourcesStorage(storage rspec.WindowsStorageResources) {
15441532
g.initSpecWindowsResources()
1545-
tmpStorage := &rspec.WindowsStorageResources{}
1546-
err := json.Unmarshal([]byte(storage), tmpStorage)
1547-
if err != nil {
1548-
return err
1549-
}
1550-
g.spec.Windows.Resources.Storage = tmpStorage
1551-
return nil
1533+
g.spec.Windows.Resources.Storage = &storage
1534+
}
1535+
1536+
// SetWinodwsServicing sets g.spec.Winodws.Servicing.
1537+
func (g *Generator) SetWinodwsServicing(servicing bool) {
1538+
g.initSpecWindows()
1539+
g.spec.Windows.Servicing = servicing
15521540
}

man/oci-runtime-tool-generate.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ read the configuration from `config.json`.
499499
Specifies storage for container.
500500
e.g. --windows-resources-storage '{"iops": 50, "bps": 20}'
501501

502+
**--windows-servicing**=true|false
503+
Whether to servicing operations
504+
502505
# EXAMPLES
503506

504507
## Generating container in read-only mode

0 commit comments

Comments
 (0)