Skip to content

Commit 3140810

Browse files
committed
Add NewContainerEdits utility function
Signed-off-by: Evan Lezar <[email protected]>
1 parent 046d761 commit 3140810

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/edits/edits.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ func FromDiscoverer(d discover.Discover) (*cdi.ContainerEdits, error) {
6464
return nil, fmt.Errorf("failed to discover hooks: %v", err)
6565
}
6666

67-
c := cdi.ContainerEdits{
68-
ContainerEdits: &specs.ContainerEdits{},
69-
}
67+
c := NewContainerEdits()
7068
for _, d := range devices {
7169
edits, err := device(d).toEdits()
7270
if err != nil {
@@ -83,7 +81,15 @@ func FromDiscoverer(d discover.Discover) (*cdi.ContainerEdits, error) {
8381
c.Append(hook(h).toEdits())
8482
}
8583

86-
return &c, nil
84+
return c, nil
85+
}
86+
87+
// NewContainerEdits is a utility function to create a CDI ContainerEdits struct.
88+
func NewContainerEdits() *cdi.ContainerEdits {
89+
c := cdi.ContainerEdits{
90+
ContainerEdits: &specs.ContainerEdits{},
91+
}
92+
return &c
8793
}
8894

8995
// Modify applies the defined edits to the incoming OCI spec

0 commit comments

Comments
 (0)