Skip to content

Commit

Permalink
network: rename getNetworkClass
Browse files Browse the repository at this point in the history
There are no classes in Go, so this function cannot return one. In fact,
it returns a new instance of NetworkInterface.

This commit drops a confusing comment, as the function does not get a
"suitable network interface". It always returns a PodInterface instance.

Signed-off-by: Dan Kenigsberg <[email protected]>
  • Loading branch information
dankenigsberg committed Jan 19, 2021
1 parent 2deeb90 commit a43b260
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions pkg/virt-launcher/virtwrap/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const primaryPodInterfaceName = "eth0"

var interfaceCacheFile = "/proc/%s/root/var/run/kubevirt-private/interface-cache-%s.json"
var vifCacheFile = "/proc/%s/root/var/run/kubevirt-private/vif-cache-%s.json"
var NetworkInterfaceFactory = getNetworkClass
var NetworkInterfaceFactory = getNewNetworkInterface

type PodCacheInterface struct {
Iface *v1.Interface `json:"iface,omitempty"`
Expand Down Expand Up @@ -134,8 +134,7 @@ func SetupNetworkInterfacesPhase2(vmi *v1.VirtualMachineInstance, domain *api.Do
return nil
}

// a factory to get suitable network interface
func getNetworkClass(network *v1.Network) (NetworkInterface, error) {
func getNewNetworkInterface(network *v1.Network) (NetworkInterface, error) {
if network.Pod != nil || network.Multus != nil {
return new(PodInterface), nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-launcher/virtwrap/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("Network", func() {
mockNetworkInterface = NewMockNetworkInterface(ctrl)
})
AfterEach(func() {
NetworkInterfaceFactory = getNetworkClass
NetworkInterfaceFactory = getNewNetworkInterface
})

Context("interface configuration", func() {
Expand Down

0 comments on commit a43b260

Please sign in to comment.