File tree 1 file changed +22
-0
lines changed
pkg/runtime-tools/generate
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,9 @@ func (g *Generator) Adjust(adjust *nri.ContainerAdjustment) error {
117
117
g .AdjustDevices (adjust .GetLinux ().GetDevices ())
118
118
g .AdjustCgroupsPath (adjust .GetLinux ().GetCgroupsPath ())
119
119
g .AdjustOomScoreAdj (adjust .GetLinux ().GetOomScoreAdj ())
120
+ if err := g .AdjustNamespaces (adjust .GetLinux ().GetNamespaces ()); err != nil {
121
+ return err
122
+ }
120
123
121
124
resources := adjust .GetLinux ().GetResources ()
122
125
if err := g .AdjustResources (resources ); err != nil {
@@ -332,6 +335,25 @@ func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt) {
332
335
}
333
336
}
334
337
338
+ // AdjustNamespaces adds or replaces namespaces in the OCI Spec.
339
+ func (g * Generator ) AdjustNamespaces (namespaces []* nri.LinuxNamespace ) error {
340
+ for _ , n := range namespaces {
341
+ if n == nil {
342
+ continue
343
+ }
344
+ if key , marked := n .IsMarkedForRemoval (); marked {
345
+ if err := g .RemoveLinuxNamespace (key ); err != nil {
346
+ return err
347
+ }
348
+ } else {
349
+ if err := g .AddOrReplaceLinuxNamespace (n .Type , n .Path ); err != nil {
350
+ return err
351
+ }
352
+ }
353
+ }
354
+ return nil
355
+ }
356
+
335
357
// AdjustDevices adjusts the (Linux) devices in the OCI Spec.
336
358
func (g * Generator ) AdjustDevices (devices []* nri.LinuxDevice ) {
337
359
for _ , d := range devices {
You can’t perform that action at this time.
0 commit comments