@@ -89,7 +89,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
8989 if err != nil {
9090 return err
9191 }
92- dev := d . ToOCI ()
92+ dev := dn . toOCI ()
9393 if dev .UID == nil && spec .Process != nil {
9494 if uid := spec .Process .User .UID ; uid > 0 {
9595 dev .UID = & uid
@@ -116,29 +116,30 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
116116 if len (e .Mounts ) > 0 {
117117 for _ , m := range e .Mounts {
118118 specgen .RemoveMount (m .ContainerPath )
119- specgen .AddMount (m . ToOCI ())
119+ specgen .AddMount (( & Mount { m }). toOCI ())
120120 }
121121 sortMounts (& specgen )
122122 }
123123
124124 for _ , h := range e .Hooks {
125+ ociHook := (& Hook {h }).toOCI ()
125126 switch h .HookName {
126127 case PrestartHook :
127- specgen .AddPreStartHook (h . ToOCI () )
128+ specgen .AddPreStartHook (ociHook )
128129 case PoststartHook :
129- specgen .AddPostStartHook (h . ToOCI () )
130+ specgen .AddPostStartHook (ociHook )
130131 case PoststopHook :
131- specgen .AddPostStopHook (h . ToOCI () )
132+ specgen .AddPostStopHook (ociHook )
132133 // TODO: Maybe runtime-tools/generate should be updated with these...
133134 case CreateRuntimeHook :
134135 ensureOCIHooks (spec )
135- spec .Hooks .CreateRuntime = append (spec .Hooks .CreateRuntime , h . ToOCI () )
136+ spec .Hooks .CreateRuntime = append (spec .Hooks .CreateRuntime , ociHook )
136137 case CreateContainerHook :
137138 ensureOCIHooks (spec )
138- spec .Hooks .CreateContainer = append (spec .Hooks .CreateContainer , h . ToOCI () )
139+ spec .Hooks .CreateContainer = append (spec .Hooks .CreateContainer , ociHook )
139140 case StartContainerHook :
140141 ensureOCIHooks (spec )
141- spec .Hooks .StartContainer = append (spec .Hooks .StartContainer , h . ToOCI () )
142+ spec .Hooks .StartContainer = append (spec .Hooks .StartContainer , ociHook )
142143 default :
143144 return fmt .Errorf ("unknown hook name %q" , h .HookName )
144145 }
@@ -148,7 +149,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
148149 // The specgen is missing functionality to set all parameters so we
149150 // just piggy-back on it to initialize all structs and the copy over.
150151 specgen .SetLinuxIntelRdtClosID (e .IntelRdt .ClosID )
151- spec .Linux .IntelRdt = e .IntelRdt . ToOCI ()
152+ spec .Linux .IntelRdt = ( & IntelRdt { e .IntelRdt }). toOCI ()
152153 }
153154
154155 for _ , additionalGID := range e .AdditionalGIDs {
@@ -186,7 +187,7 @@ func (e *ContainerEdits) Validate() error {
186187 }
187188 }
188189 if e .IntelRdt != nil {
189- if err := ValidateIntelRdt ( e .IntelRdt ); err != nil {
190+ if err := ( & IntelRdt { e .IntelRdt }). Validate ( ); err != nil {
190191 return err
191192 }
192193 }
@@ -321,8 +322,21 @@ func (m *Mount) Validate() error {
321322 return nil
322323}
323324
325+ // IntelRdt is a CDI IntelRdt wrapper.
326+ // This is used for validation and conversion to OCI specifications.
327+ type IntelRdt struct {
328+ * specs.IntelRdt
329+ }
330+
324331// ValidateIntelRdt validates the IntelRdt configuration.
332+ //
333+ // Deprecated: ValidateIntelRdt is deprecated use IntelRdt.Validate() instead.
325334func ValidateIntelRdt (i * specs.IntelRdt ) error {
335+ return (& IntelRdt {i }).Validate ()
336+ }
337+
338+ // Validate validates the IntelRdt configuration.
339+ func (i * IntelRdt ) Validate () error {
326340 // ClosID must be a valid Linux filename
327341 if len (i .ClosID ) >= 4096 || i .ClosID == "." || i .ClosID == ".." || strings .ContainsAny (i .ClosID , "/\n " ) {
328342 return errors .New ("invalid ClosID" )
0 commit comments