From f436a990507f6f24e0c6a8e7e8fb3decb9fbbbd0 Mon Sep 17 00:00:00 2001 From: Ritu Sood Date: Fri, 7 Jun 2019 13:33:56 -0700 Subject: Fix for format issues No code change made. Only corrected the formatting of some files. Change-Id: I1ccb4a0fddcc65bd7d3f93312c5417e7830fed5a Signed-off-by: Ritu Sood --- cmd/ovn4nfvk8s-cni/ovn4nfvk8s-cni.go | 97 ++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 49 deletions(-) (limited to 'cmd/ovn4nfvk8s-cni/ovn4nfvk8s-cni.go') diff --git a/cmd/ovn4nfvk8s-cni/ovn4nfvk8s-cni.go b/cmd/ovn4nfvk8s-cni/ovn4nfvk8s-cni.go index ec37c02..3a6b7f0 100644 --- a/cmd/ovn4nfvk8s-cni/ovn4nfvk8s-cni.go +++ b/cmd/ovn4nfvk8s-cni/ovn4nfvk8s-cni.go @@ -196,51 +196,50 @@ func addMultipleInterfaces(args *skel.CmdArgs, ovnAnnotation, namespace, podName } func addRoutes(args *skel.CmdArgs, ovnAnnotation string, dstResult types.Result) types.Result { - logrus.Infof("ovn4nfvk8s-cni: addRoutes ") - - var ovnAnnotatedMap []map[string]string - ovnAnnotatedMap, err := parseOvnNetworkObject(ovnAnnotation) - if err != nil { - logrus.Errorf("addLogicalPort : Error Parsing Ovn Route List %v", err) - return nil - } - - var result types.Result - var routes []*types.Route - for _, ovnNet := range ovnAnnotatedMap { - dst := ovnNet["dst"] - gw := ovnNet["gw"] - dev := ovnNet["dev"] - if dst == "" || gw == "" || dev == "" { - logrus.Errorf("failed in pod annotation key extract") - return nil - } - err = app.ConfigureRoute(args, dst, gw, dev) - if err != nil { - logrus.Errorf("Failed to configure interface in pod: %v", err) - return nil - } - dstAddr, dstAddrNet, _ := net.ParseCIDR(dst) - routes = append(routes, &types.Route{ - Dst: net.IPNet{IP: dstAddr, Mask: dstAddrNet.Mask}, - GW: net.ParseIP(gw), - }) - } - - result = ¤t.Result{ - Routes: routes, - } - // Build the result structure to pass back to the runtime - dstResult, err = mergeWithResult(result, dstResult) - if err != nil { - logrus.Errorf("Failed to merge results: %v", err) - return nil - } - logrus.Infof("addRoutes: %s", prettyPrint(dstResult)) - return dstResult + logrus.Infof("ovn4nfvk8s-cni: addRoutes ") -} + var ovnAnnotatedMap []map[string]string + ovnAnnotatedMap, err := parseOvnNetworkObject(ovnAnnotation) + if err != nil { + logrus.Errorf("addLogicalPort : Error Parsing Ovn Route List %v", err) + return nil + } + + var result types.Result + var routes []*types.Route + for _, ovnNet := range ovnAnnotatedMap { + dst := ovnNet["dst"] + gw := ovnNet["gw"] + dev := ovnNet["dev"] + if dst == "" || gw == "" || dev == "" { + logrus.Errorf("failed in pod annotation key extract") + return nil + } + err = app.ConfigureRoute(args, dst, gw, dev) + if err != nil { + logrus.Errorf("Failed to configure interface in pod: %v", err) + return nil + } + dstAddr, dstAddrNet, _ := net.ParseCIDR(dst) + routes = append(routes, &types.Route{ + Dst: net.IPNet{IP: dstAddr, Mask: dstAddrNet.Mask}, + GW: net.ParseIP(gw), + }) + } + + result = ¤t.Result{ + Routes: routes, + } + // Build the result structure to pass back to the runtime + dstResult, err = mergeWithResult(result, dstResult) + if err != nil { + logrus.Errorf("Failed to merge results: %v", err) + return nil + } + logrus.Infof("addRoutes: %s", prettyPrint(dstResult)) + return dstResult +} func cmdAdd(args *skel.CmdArgs) error { logrus.Infof("ovn4nfvk8s-cni: cmdAdd ") @@ -289,12 +288,12 @@ func cmdAdd(args *skel.CmdArgs) error { return fmt.Errorf("Error while obtaining pod annotations") } result := addMultipleInterfaces(args, ovnAnnotation, namespace, podName) - // Add Routes to the pod if annotation found for routes - ovnRouteAnnotation, ok := annotation["ovnNetworkRoutes"] - if ok { - logrus.Infof("ovn4nfvk8s-cni: ovnNetworkRoutes Annotation Found %+v", ovnRouteAnnotation) - result = addRoutes(args, ovnRouteAnnotation, result) - } + // Add Routes to the pod if annotation found for routes + ovnRouteAnnotation, ok := annotation["ovnNetworkRoutes"] + if ok { + logrus.Infof("ovn4nfvk8s-cni: ovnNetworkRoutes Annotation Found %+v", ovnRouteAnnotation) + result = addRoutes(args, ovnRouteAnnotation, result) + } return result.Print() } -- cgit 1.2.3-korg