File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
pkg/runtime-tools/generate Expand file tree Collapse file tree 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 {
117117 g .AdjustDevices (adjust .GetLinux ().GetDevices ())
118118 g .AdjustCgroupsPath (adjust .GetLinux ().GetCgroupsPath ())
119119 g .AdjustOomScoreAdj (adjust .GetLinux ().GetOomScoreAdj ())
120+ if err := g .AdjustNamespaces (adjust .GetLinux ().GetNamespaces ()); err != nil {
121+ return err
122+ }
120123
121124 resources := adjust .GetLinux ().GetResources ()
122125 if err := g .AdjustResources (resources ); err != nil {
@@ -332,6 +335,25 @@ func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt) {
332335 }
333336}
334337
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+
335357// AdjustDevices adjusts the (Linux) devices in the OCI Spec.
336358func (g * Generator ) AdjustDevices (devices []* nri.LinuxDevice ) {
337359 for _ , d := range devices {
You can’t perform that action at this time.
0 commit comments