Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
network: Allow convertToInterface to fail
Browse files Browse the repository at this point in the history
There's nothing in there which can fail now, but I'm planning to add
something, and it turns out it's pretty easy for the single caller to
handle.

Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
dgibson committed Oct 27, 2020
1 parent 185b3ab commit bfbfab3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,10 @@ func (k *kataAgent) listInterfaces() ([]*vcTypes.Interface, error) {
}
resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces)
if ok {
return k.convertToInterfaces(resultInterfaces.Interfaces), err
ifaces, err := k.convertToInterfaces(resultInterfaces.Interfaces)
if err == nil {
return ifaces, nil
}
}
return nil, err
}
Expand Down Expand Up @@ -2301,7 +2304,8 @@ func (k *kataAgent) convertToKataAgentInterface(iface *vcTypes.Interface) *aType
}
}

func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*vcTypes.Interface) {
func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) ([]*vcTypes.Interface, error) {
ifaces := make([]*vcTypes.Interface, 0)
for _, aIface := range aIfaces {
if aIface == nil {
continue
Expand All @@ -2319,7 +2323,7 @@ func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*
ifaces = append(ifaces, iface)
}

return ifaces
return ifaces, nil
}

func (k *kataAgent) convertToKataAgentRoutes(routes []*vcTypes.Route) (aRoutes []*aTypes.Route) {
Expand Down

0 comments on commit bfbfab3

Please sign in to comment.