@@ -89,7 +89,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
89
89
if err != nil {
90
90
return err
91
91
}
92
- dev := d .ToOCI ()
92
+ dev := dn .ToOCI ()
93
93
if dev .UID == nil && spec .Process != nil {
94
94
if uid := spec .Process .User .UID ; uid > 0 {
95
95
dev .UID = & uid
@@ -116,29 +116,30 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
116
116
if len (e .Mounts ) > 0 {
117
117
for _ , m := range e .Mounts {
118
118
specgen .RemoveMount (m .ContainerPath )
119
- specgen .AddMount (m .ToOCI ())
119
+ specgen .AddMount (( & Mount { m }) .ToOCI ())
120
120
}
121
121
sortMounts (& specgen )
122
122
}
123
123
124
124
for _ , h := range e .Hooks {
125
+ ociHook := (& Hook {h }).ToOCI ()
125
126
switch h .HookName {
126
127
case PrestartHook :
127
- specgen .AddPreStartHook (h . ToOCI () )
128
+ specgen .AddPreStartHook (ociHook )
128
129
case PoststartHook :
129
- specgen .AddPostStartHook (h . ToOCI () )
130
+ specgen .AddPostStartHook (ociHook )
130
131
case PoststopHook :
131
- specgen .AddPostStopHook (h . ToOCI () )
132
+ specgen .AddPostStopHook (ociHook )
132
133
// TODO: Maybe runtime-tools/generate should be updated with these...
133
134
case CreateRuntimeHook :
134
135
ensureOCIHooks (spec )
135
- spec .Hooks .CreateRuntime = append (spec .Hooks .CreateRuntime , h . ToOCI () )
136
+ spec .Hooks .CreateRuntime = append (spec .Hooks .CreateRuntime , ociHook )
136
137
case CreateContainerHook :
137
138
ensureOCIHooks (spec )
138
- spec .Hooks .CreateContainer = append (spec .Hooks .CreateContainer , h . ToOCI () )
139
+ spec .Hooks .CreateContainer = append (spec .Hooks .CreateContainer , ociHook )
139
140
case StartContainerHook :
140
141
ensureOCIHooks (spec )
141
- spec .Hooks .StartContainer = append (spec .Hooks .StartContainer , h . ToOCI () )
142
+ spec .Hooks .StartContainer = append (spec .Hooks .StartContainer , ociHook )
142
143
default :
143
144
return fmt .Errorf ("unknown hook name %q" , h .HookName )
144
145
}
@@ -148,7 +149,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
148
149
// The specgen is missing functionality to set all parameters so we
149
150
// just piggy-back on it to initialize all structs and the copy over.
150
151
specgen .SetLinuxIntelRdtClosID (e .IntelRdt .ClosID )
151
- spec .Linux .IntelRdt = e .IntelRdt .ToOCI ()
152
+ spec .Linux .IntelRdt = ( & IntelRdt { e .IntelRdt }) .ToOCI ()
152
153
}
153
154
154
155
for _ , additionalGID := range e .AdditionalGIDs {
@@ -186,7 +187,7 @@ func (e *ContainerEdits) Validate() error {
186
187
}
187
188
}
188
189
if e .IntelRdt != nil {
189
- if err := ValidateIntelRdt ( e .IntelRdt ); err != nil {
190
+ if err := ( & IntelRdt { e .IntelRdt }). Validate ( ); err != nil {
190
191
return err
191
192
}
192
193
}
@@ -321,8 +322,21 @@ func (m *Mount) Validate() error {
321
322
return nil
322
323
}
323
324
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
+
324
331
// ValidateIntelRdt validates the IntelRdt configuration.
332
+ //
333
+ // Deprecated: ValidateIntelRdt is deprecated use IntelRdt.Validate() instead.
325
334
func ValidateIntelRdt (i * specs.IntelRdt ) error {
335
+ return (& IntelRdt {i }).Validate ()
336
+ }
337
+
338
+ // Validate validates the IntelRdt configuration.
339
+ func (i * IntelRdt ) Validate () error {
326
340
// ClosID must be a valid Linux filename
327
341
if len (i .ClosID ) >= 4096 || i .ClosID == "." || i .ClosID == ".." || strings .ContainsAny (i .ClosID , "/\n " ) {
328
342
return errors .New ("invalid ClosID" )
0 commit comments