Skip to content

Commit 7d96b13

Browse files
committed
fixup! specs-go,cdi: implement NetDevice injection.
1 parent 219cf6d commit 7d96b13

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

pkg/cdi/container-edits.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (e *ContainerEdits) Apply(spec *oci.Spec) error {
117117
// specgen is currently missing functionality to set Linux NetDevices,
118118
// so we use a locally rolled function for now.
119119
for _, dev := range e.NetDevices {
120-
specgenAddLinuxNetDevice(&specgen, dev.HostInterface, (&LinuxNetDevice{dev}).toOCI())
120+
specgenAddLinuxNetDevice(&specgen, dev.HostInterfaceName, (&LinuxNetDevice{dev}).toOCI())
121121
}
122122
}
123123

@@ -301,17 +301,17 @@ func ValidateNetDevices(devices []*cdi.LinuxNetDevice) error {
301301
if err := (&LinuxNetDevice{dev}).Validate(); err != nil {
302302
return err
303303
}
304-
if other, ok := hostSeen[dev.HostInterface]; ok {
305-
return fmt.Errorf("invalid linux net device, duplicate HostInterface %q with names %q and %q",
306-
dev.HostInterface, dev.Name, other)
304+
if other, ok := hostSeen[dev.HostInterfaceName]; ok {
305+
return fmt.Errorf("invalid linux net device, duplicate HostInterfaceName %q with names %q and %q",
306+
dev.HostInterfaceName, dev.Name, other)
307307
}
308-
hostSeen[dev.HostInterface] = dev.Name
308+
hostSeen[dev.HostInterfaceName] = dev.Name
309309

310310
if other, ok := nameSeen[dev.Name]; ok {
311-
return fmt.Errorf("invalid linux net device, duplicate Name %q with HostInterface %q and %q",
312-
dev.Name, dev.HostInterface, other)
311+
return fmt.Errorf("invalid linux net device, duplicate Name %q with HostInterfaceName %q and %q",
312+
dev.Name, dev.HostInterfaceName, other)
313313
}
314-
nameSeen[dev.Name] = dev.HostInterface
314+
nameSeen[dev.Name] = dev.HostInterfaceName
315315
}
316316

317317
return nil
@@ -324,8 +324,8 @@ type LinuxNetDevice struct {
324324

325325
// Validate LinuxNetDevice.
326326
func (d *LinuxNetDevice) Validate() error {
327-
if d.HostInterface == "" {
328-
return errors.New("invalid linux net device, empty HostInterface")
327+
if d.HostInterfaceName == "" {
328+
return errors.New("invalid linux net device, empty HostInterfaceName")
329329
}
330330
if d.Name == "" {
331331
return errors.New("invalid linux net device, empty Name")

pkg/cdi/container-edits_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ func TestValidateContainerEdits(t *testing.T) {
304304
edits: &cdi.ContainerEdits{
305305
NetDevices: []*cdi.LinuxNetDevice{
306306
{
307-
HostInterface: "eno1",
308-
Name: "netdev0",
307+
HostInterfaceName: "eno1",
308+
Name: "netdev0",
309309
},
310310
},
311311
},
@@ -315,8 +315,8 @@ func TestValidateContainerEdits(t *testing.T) {
315315
edits: &cdi.ContainerEdits{
316316
NetDevices: []*cdi.LinuxNetDevice{
317317
{
318-
HostInterface: "",
319-
Name: "netdev0",
318+
HostInterfaceName: "",
319+
Name: "netdev0",
320320
},
321321
},
322322
},
@@ -327,8 +327,8 @@ func TestValidateContainerEdits(t *testing.T) {
327327
edits: &cdi.ContainerEdits{
328328
NetDevices: []*cdi.LinuxNetDevice{
329329
{
330-
HostInterface: "eno1",
331-
Name: "",
330+
HostInterfaceName: "eno1",
331+
Name: "",
332332
},
333333
},
334334
},
@@ -628,12 +628,12 @@ func TestApplyContainerEdits(t *testing.T) {
628628
edits: &cdi.ContainerEdits{
629629
NetDevices: []*cdi.LinuxNetDevice{
630630
{
631-
HostInterface: "eno1",
632-
Name: "netdev0",
631+
HostInterfaceName: "eno1",
632+
Name: "netdev0",
633633
},
634634
{
635-
HostInterface: "eno2",
636-
Name: "netdev1",
635+
HostInterfaceName: "eno2",
636+
Name: "netdev1",
637637
},
638638
},
639639
},
@@ -664,12 +664,12 @@ func TestApplyContainerEdits(t *testing.T) {
664664
edits: &cdi.ContainerEdits{
665665
NetDevices: []*cdi.LinuxNetDevice{
666666
{
667-
HostInterface: "eno1",
668-
Name: "netdev2",
667+
HostInterfaceName: "eno1",
668+
Name: "netdev2",
669669
},
670670
{
671-
HostInterface: "eno2",
672-
Name: "netdev1",
671+
HostInterfaceName: "eno2",
672+
Name: "netdev1",
673673
},
674674
},
675675
},

specs-go/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ type IntelRdt struct {
7474

7575
// LinuxNetDevice represents an OCI LinuxNetDevice to be added to the OCI Spec.
7676
type LinuxNetDevice struct {
77-
HostInterface string `json:"hostInterface" yaml:"hostInterface"`
78-
Name string `json:"name" yaml:"name"`
77+
HostInterfaceName string `json:"hostInterfaceName" yaml:"hostInterfaceName"`
78+
Name string `json:"name" yaml:"name"`
7979
}

0 commit comments

Comments
 (0)