flannel: set the cniVersion on the delegated config
authorCasey Callendrello <casey.callendrello@coreos.com>
Fri, 16 Jun 2017 17:04:07 +0000 (19:04 +0200)
committerCasey Callendrello <casey.callendrello@coreos.com>
Fri, 16 Jun 2017 17:04:07 +0000 (19:04 +0200)
Fixes: #23

plugins/meta/flannel/flannel.go
plugins/meta/flannel/flannel_test.go

index 424e01b..6ec0e8f 100644 (file)
@@ -224,6 +224,9 @@ func cmdAdd(args *skel.CmdArgs) error {
                        n.Delegate["isGateway"] = true
                }
        }
+       if n.CNIVersion != "" {
+               n.Delegate["cniVersion"] = n.CNIVersion
+       }
 
        n.Delegate["ipam"] = map[string]interface{}{
                "type":   "host-local",
index 0380729..94a0de8 100644 (file)
@@ -19,6 +19,7 @@ import (
        "os"
 
        "github.com/containernetworking/cni/pkg/skel"
+       "github.com/containernetworking/cni/pkg/types/current"
        "github.com/containernetworking/plugins/pkg/ns"
        "github.com/containernetworking/plugins/pkg/testutils"
 
@@ -102,7 +103,7 @@ FLANNEL_IPMASQ=true
                                defer GinkgoRecover()
 
                                By("calling ADD")
-                               _, _, err := testutils.CmdAddWithResult(targetNs.Path(), IFNAME, []byte(input), func() error {
+                               resI, _, err := testutils.CmdAddWithResult(targetNs.Path(), IFNAME, []byte(input), func() error {
                                        return cmdAdd(args)
                                })
                                Expect(err).NotTo(HaveOccurred())
@@ -132,6 +133,10 @@ FLANNEL_IPMASQ=true
 `
                                Expect(netConfBytes).Should(MatchJSON(expected))
 
+                               result, err := current.NewResultFromResult(resI)
+                               Expect(err).NotTo(HaveOccurred())
+                               Expect(result.IPs).To(HaveLen(1))
+
                                By("calling DEL")
                                err = testutils.CmdDelWithResult(targetNs.Path(), IFNAME, func() error {
                                        return cmdDel(args)