@@ -19,6 +19,7 @@ package oci
1919import (
2020 "context"
2121 "path/filepath"
22+ "runtime"
2223
2324 "github.com/containerd/containerd/namespaces"
2425 "github.com/containerd/containerd/platforms"
@@ -51,22 +52,30 @@ func GenerateSpec(ctx context.Context, client Client, c *containers.Container, o
5152// GenerateSpecWithPlatform will generate a default spec from the provided image
5253// for use as a containerd container in the platform requested.
5354func GenerateSpecWithPlatform (ctx context.Context , client Client , platform string , c * containers.Container , opts ... SpecOpts ) (* Spec , error ) {
55+ var s Spec
56+ if err := generateDefaultSpecWithPlatform (ctx , platform , c .ID , & s ); err != nil {
57+ return nil , err
58+ }
59+
60+ return & s , ApplyOpts (ctx , client , c , & s , opts ... )
61+ }
62+
63+ func generateDefaultSpecWithPlatform (ctx context.Context , platform , id string , s * Spec ) error {
5464 plat , err := platforms .Parse (platform )
5565 if err != nil {
56- return nil , err
66+ return err
5767 }
5868
59- var s Spec
6069 if plat .OS == "windows" {
61- err = populateDefaultWindowsSpec (ctx , & s , c . ID )
70+ err = populateDefaultWindowsSpec (ctx , s , id )
6271 } else {
63- err = populateDefaultUnixSpec (ctx , & s , c .ID )
64- }
65- if err != nil {
66- return nil , err
72+ err = populateDefaultUnixSpec (ctx , s , id )
73+ if err == nil && runtime .GOOS == "windows" {
74+ // To run LCOW we have a Linux and Windows section. Add an empty one now.
75+ s .Windows = & specs.Windows {}
76+ }
6777 }
68-
69- return & s , ApplyOpts (ctx , client , c , & s , opts ... )
78+ return err
7079}
7180
7281// ApplyOpts applys the options to the given spec, injecting data from the
0 commit comments