mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Add sorter to simplifying transformer
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
7a4d2cff67
commit
cbdbcd87ff
@ -163,6 +163,18 @@ func TestMergedDevice(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedSpec: &specs.Spec{
|
expectedSpec: &specs.Spec{
|
||||||
Devices: []specs.Device{
|
Devices: []specs.Device{
|
||||||
|
{
|
||||||
|
Name: "all",
|
||||||
|
ContainerEdits: specs.ContainerEdits{
|
||||||
|
Hooks: []*specs.Hook{
|
||||||
|
{
|
||||||
|
HookName: "createContainer",
|
||||||
|
Path: "/usr/bin/nvidia-ctk",
|
||||||
|
Args: []string{"nvidia-ctk", "hook", "chmod", "--mode", "755", "--path", "/dev/dri"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "gpu0",
|
Name: "gpu0",
|
||||||
ContainerEdits: specs.ContainerEdits{
|
ContainerEdits: specs.ContainerEdits{
|
||||||
@ -187,18 +199,6 @@ func TestMergedDevice(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "all",
|
|
||||||
ContainerEdits: specs.ContainerEdits{
|
|
||||||
Hooks: []*specs.Hook{
|
|
||||||
{
|
|
||||||
HookName: "createContainer",
|
|
||||||
Path: "/usr/bin/nvidia-ctk",
|
|
||||||
Args: []string{"nvidia-ctk", "hook", "chmod", "--mode", "755", "--path", "/dev/dri"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,11 @@ var _ Transformer = (*simplify)(nil)
|
|||||||
// NewSimplifier creates a simplifier transformer.
|
// NewSimplifier creates a simplifier transformer.
|
||||||
// This transoformer ensures that entities in the spec are deduplicated and that common edits are removed from device-specific edits.
|
// This transoformer ensures that entities in the spec are deduplicated and that common edits are removed from device-specific edits.
|
||||||
func NewSimplifier() Transformer {
|
func NewSimplifier() Transformer {
|
||||||
return &simplify{}
|
return Merge(
|
||||||
|
dedupe{},
|
||||||
|
simplify{},
|
||||||
|
sorter{},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform simplifies the supplied spec.
|
// Transform simplifies the supplied spec.
|
||||||
|
Loading…
Reference in New Issue
Block a user