@@ -47,11 +47,11 @@ func ApplyEditsToOCISpec(config *spec.Spec, edits *ContainerEdits) error {
4747 if config .Linux == nil {
4848 config .Linux = & spec.Linux {}
4949 }
50- config .Linux .Devices = append (config .Linux .Devices , toOCILinuxDevice ( d ))
50+ config .Linux .Devices = append (config .Linux .Devices , d . ToOCI ( ))
5151 }
5252
5353 for _ , m := range edits .Mounts {
54- config .Mounts = append (config .Mounts , toOCIMount ( m ))
54+ config .Mounts = append (config .Mounts , m . ToOCI ( ))
5555 }
5656
5757 for _ , h := range edits .Hooks {
@@ -60,17 +60,17 @@ func ApplyEditsToOCISpec(config *spec.Spec, edits *ContainerEdits) error {
6060 }
6161 switch h .HookName {
6262 case "prestart" :
63- config .Hooks .Prestart = append (config .Hooks .Prestart , toOCIHook ( h ))
63+ config .Hooks .Prestart = append (config .Hooks .Prestart , h . ToOCI ( ))
6464 case "createRuntime" :
65- config .Hooks .CreateRuntime = append (config .Hooks .CreateRuntime , toOCIHook ( h ))
65+ config .Hooks .CreateRuntime = append (config .Hooks .CreateRuntime , h . ToOCI ( ))
6666 case "createContainer" :
67- config .Hooks .CreateContainer = append (config .Hooks .CreateContainer , toOCIHook ( h ))
67+ config .Hooks .CreateContainer = append (config .Hooks .CreateContainer , h . ToOCI ( ))
6868 case "startContainer" :
69- config .Hooks .StartContainer = append (config .Hooks .StartContainer , toOCIHook ( h ))
69+ config .Hooks .StartContainer = append (config .Hooks .StartContainer , h . ToOCI ( ))
7070 case "poststart" :
71- config .Hooks .Poststart = append (config .Hooks .Poststart , toOCIHook ( h ))
71+ config .Hooks .Poststart = append (config .Hooks .Poststart , h . ToOCI ( ))
7272 case "poststop" :
73- config .Hooks .Poststop = append (config .Hooks .Poststop , toOCIHook ( h ))
73+ config .Hooks .Poststop = append (config .Hooks .Poststop , h . ToOCI ( ))
7474 default :
7575 fmt .Printf ("CDI: Unknown hook %q\n " , h .HookName )
7676 }
@@ -79,7 +79,8 @@ func ApplyEditsToOCISpec(config *spec.Spec, edits *ContainerEdits) error {
7979 return nil
8080}
8181
82- func toOCIHook (h * Hook ) spec.Hook {
82+ // ToOCI returns the opencontainers runtime Spec Hook for this Hook.
83+ func (h * Hook ) ToOCI () spec.Hook {
8384 return spec.Hook {
8485 Path : h .Path ,
8586 Args : h .Args ,
@@ -88,15 +89,17 @@ func toOCIHook(h *Hook) spec.Hook {
8889 }
8990}
9091
91- func toOCIMount (m * Mount ) spec.Mount {
92+ // ToOCI returns the opencontainers runtime Spec Mount for this Mount.
93+ func (m * Mount ) ToOCI () spec.Mount {
9294 return spec.Mount {
9395 Source : m .HostPath ,
9496 Destination : m .ContainerPath ,
9597 Options : m .Options ,
9698 }
9799}
98100
99- func toOCILinuxDevice (d * DeviceNode ) spec.LinuxDevice {
101+ // ToOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode.
102+ func (d * DeviceNode ) ToOCI () spec.LinuxDevice {
100103 return spec.LinuxDevice {
101104 Path : d .Path ,
102105 Type : d .Type ,
0 commit comments