diff --git a/internal/edits/edits.go b/internal/edits/edits.go index d7795fd7..96d40c60 100644 --- a/internal/edits/edits.go +++ b/internal/edits/edits.go @@ -64,9 +64,7 @@ func FromDiscoverer(d discover.Discover) (*cdi.ContainerEdits, error) { return nil, fmt.Errorf("failed to discover hooks: %v", err) } - c := cdi.ContainerEdits{ - ContainerEdits: &specs.ContainerEdits{}, - } + c := NewContainerEdits() for _, d := range devices { edits, err := device(d).toEdits() if err != nil { @@ -83,7 +81,15 @@ func FromDiscoverer(d discover.Discover) (*cdi.ContainerEdits, error) { c.Append(hook(h).toEdits()) } - return &c, nil + return c, nil +} + +// NewContainerEdits is a utility function to create a CDI ContainerEdits struct. +func NewContainerEdits() *cdi.ContainerEdits { + c := cdi.ContainerEdits{ + ContainerEdits: &specs.ContainerEdits{}, + } + return &c } // Modify applies the defined edits to the incoming OCI spec