Skip to content

Commit 8e194a2

Browse files
committed
runtime-tools/generate: adjust LinuxNamespaces
Signed-off-by: Etienne Champetier <[email protected]>
1 parent 4143b10 commit 8e194a2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/runtime-tools/generate/generate.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ 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+
g.AdjustNamespaces(adjust.GetLinux().GetNamespaces())
120121

121122
resources := adjust.GetLinux().GetResources()
122123
if err := g.AdjustResources(resources); err != nil {
@@ -332,6 +333,21 @@ func (g *Generator) AdjustOomScoreAdj(score *nri.OptionalInt) {
332333
}
333334
}
334335

336+
// AdjustNamespaces adds or replaces namespaces in the OCI Spec.
337+
func (g *Generator) AdjustNamespaces(namespaces []*nri.LinuxNamespace) error {
338+
for _, n := range namespaces {
339+
if n == nil {
340+
continue
341+
}
342+
if key, marked := n.IsMarkedForRemoval(); marked {
343+
g.RemoveLinuxNamespace(key)
344+
} else {
345+
g.AddOrReplaceLinuxNamespace(n.Type, n.Path)
346+
}
347+
}
348+
return nil
349+
}
350+
335351
// AdjustDevices adjusts the (Linux) devices in the OCI Spec.
336352
func (g *Generator) AdjustDevices(devices []*nri.LinuxDevice) {
337353
for _, d := range devices {

0 commit comments

Comments
 (0)