Skip to content

Commit

Permalink
runtime-tools/generate: adjust LinuxNamespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
  • Loading branch information
champtar committed Jan 23, 2025
1 parent 6a81b01 commit 91fba35
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/runtime-tools/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (g *Generator) Adjust(adjust *nri.ContainerAdjustment) error {
g.AdjustDevices(adjust.GetLinux().GetDevices())
g.AdjustCgroupsPath(adjust.GetLinux().GetCgroupsPath())
g.AdjustOomScoreAdj(adjust.GetLinux().GetOomScoreAdj())
g.AdjustNamespaces(adjust.GetLinux().GetNamespaces())

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

// AdjustNamespaces adds or replaces namespaces in the OCI Spec.
func (g *Generator) AdjustNamespaces(namespaces []*nri.LinuxNamespace) error {
for _, n := range namespaces {
if n == nil {
continue
}
if key, marked := n.IsMarkedForRemoval(); marked {
g.RemoveLinuxNamespace(key)
} else {
g.AddOrReplaceLinuxNamespace(n.Type, n.Path)
}
}
return nil
}

// AdjustDevices adjusts the (Linux) devices in the OCI Spec.
func (g *Generator) AdjustDevices(devices []*nri.LinuxDevice) {
for _, d := range devices {
Expand Down

0 comments on commit 91fba35

Please sign in to comment.