vendor: bump cni to 0.5.2-git49d814c
authorDan Williams <dcbw@redhat.com>
Thu, 22 Jun 2017 14:44:41 +0000 (09:44 -0500)
committerDan Williams <dcbw@redhat.com>
Wed, 28 Jun 2017 17:06:37 +0000 (12:06 -0500)
Godeps/Godeps.json
vendor/github.com/containernetworking/cni/pkg/invoke/args.go
vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec.go
vendor/github.com/containernetworking/cni/pkg/types/020/types.go
vendor/github.com/containernetworking/cni/pkg/types/current/types.go
vendor/github.com/containernetworking/cni/pkg/types/types.go

index 9970c36..feec505 100644 (file)
@@ -8,38 +8,38 @@
        "Deps": [
                {
                        "ImportPath": "github.com/containernetworking/cni/libcni",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/containernetworking/cni/pkg/invoke",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/containernetworking/cni/pkg/skel",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/containernetworking/cni/pkg/types",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/containernetworking/cni/pkg/types/020",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/containernetworking/cni/pkg/types/current",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/containernetworking/cni/pkg/version",
-                       "Comment": "v0.5.2",
-                       "Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
+                       "Comment": "v0.5.2-git49d814c",
+                       "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
                },
                {
                        "ImportPath": "github.com/coreos/go-iptables/iptables",
index ba9d0c3..39b6397 100644 (file)
@@ -57,13 +57,16 @@ func (args *Args) AsEnv() []string {
                pluginArgsStr = stringify(args.PluginArgs)
        }
 
-       env = append(env,
-               "CNI_COMMAND="+args.Command,
-               "CNI_CONTAINERID="+args.ContainerID,
-               "CNI_NETNS="+args.NetNS,
-               "CNI_ARGS="+pluginArgsStr,
-               "CNI_IFNAME="+args.IfName,
-               "CNI_PATH="+args.Path)
+       // Ensure that the custom values are first, so any value present in
+       // the process environment won't override them.
+       env = append([]string{
+               "CNI_COMMAND=" + args.Command,
+               "CNI_CONTAINERID=" + args.ContainerID,
+               "CNI_NETNS=" + args.NetNS,
+               "CNI_ARGS=" + pluginArgsStr,
+               "CNI_IFNAME=" + args.IfName,
+               "CNI_PATH=" + args.Path,
+       }, env...)
        return env
 }
 
index d1bd860..93f1e75 100644 (file)
@@ -50,13 +50,9 @@ func pluginErr(err error, output []byte) error {
        if _, ok := err.(*exec.ExitError); ok {
                emsg := types.Error{}
                if perr := json.Unmarshal(output, &emsg); perr != nil {
-                       return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
+                       emsg.Msg = fmt.Sprintf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
                }
-               details := ""
-               if emsg.Details != "" {
-                       details = fmt.Sprintf("; %v", emsg.Details)
-               }
-               return fmt.Errorf("%v%v", emsg.Msg, details)
+               return &emsg
        }
 
        return err
index 666cfe9..2833aba 100644 (file)
@@ -23,9 +23,9 @@ import (
        "github.com/containernetworking/cni/pkg/types"
 )
 
-const implementedSpecVersion string = "0.2.0"
+const ImplementedSpecVersion string = "0.2.0"
 
-var SupportedVersions = []string{"", "0.1.0", implementedSpecVersion}
+var SupportedVersions = []string{"", "0.1.0", ImplementedSpecVersion}
 
 // Compatibility types for CNI version 0.1.0 and 0.2.0
 
@@ -39,7 +39,7 @@ func NewResult(data []byte) (types.Result, error) {
 
 func GetResult(r types.Result) (*Result, error) {
        // We expect version 0.1.0/0.2.0 results
-       result020, err := r.GetAsVersion(implementedSpecVersion)
+       result020, err := r.GetAsVersion(ImplementedSpecVersion)
        if err != nil {
                return nil, err
        }
@@ -52,18 +52,20 @@ func GetResult(r types.Result) (*Result, error) {
 
 // Result is what gets returned from the plugin (via stdout) to the caller
 type Result struct {
-       IP4 *IPConfig `json:"ip4,omitempty"`
-       IP6 *IPConfig `json:"ip6,omitempty"`
-       DNS types.DNS `json:"dns,omitempty"`
+       CNIVersion string    `json:"cniVersion,omitempty"`
+       IP4        *IPConfig `json:"ip4,omitempty"`
+       IP6        *IPConfig `json:"ip6,omitempty"`
+       DNS        types.DNS `json:"dns,omitempty"`
 }
 
 func (r *Result) Version() string {
-       return implementedSpecVersion
+       return ImplementedSpecVersion
 }
 
 func (r *Result) GetAsVersion(version string) (types.Result, error) {
        for _, supportedVersion := range SupportedVersions {
                if version == supportedVersion {
+                       r.CNIVersion = version
                        return r, nil
                }
        }
index b89a5d3..caac92b 100644 (file)
@@ -24,9 +24,9 @@ import (
        "github.com/containernetworking/cni/pkg/types/020"
 )
 
-const implementedSpecVersion string = "0.3.1"
+const ImplementedSpecVersion string = "0.3.1"
 
-var SupportedVersions = []string{"0.3.0", implementedSpecVersion}
+var SupportedVersions = []string{"0.3.0", ImplementedSpecVersion}
 
 func NewResult(data []byte) (types.Result, error) {
        result := &Result{}
@@ -37,7 +37,7 @@ func NewResult(data []byte) (types.Result, error) {
 }
 
 func GetResult(r types.Result) (*Result, error) {
-       resultCurrent, err := r.GetAsVersion(implementedSpecVersion)
+       resultCurrent, err := r.GetAsVersion(ImplementedSpecVersion)
        if err != nil {
                return nil, err
        }
@@ -63,16 +63,16 @@ func convertFrom020(result types.Result) (*Result, error) {
        }
 
        newResult := &Result{
-               DNS:    oldResult.DNS,
-               Routes: []*types.Route{},
+               CNIVersion: ImplementedSpecVersion,
+               DNS:        oldResult.DNS,
+               Routes:     []*types.Route{},
        }
 
        if oldResult.IP4 != nil {
                newResult.IPs = append(newResult.IPs, &IPConfig{
-                       Version:   "4",
-                       Interface: -1,
-                       Address:   oldResult.IP4.IP,
-                       Gateway:   oldResult.IP4.Gateway,
+                       Version: "4",
+                       Address: oldResult.IP4.IP,
+                       Gateway: oldResult.IP4.Gateway,
                })
                for _, route := range oldResult.IP4.Routes {
                        gw := route.GW
@@ -88,10 +88,9 @@ func convertFrom020(result types.Result) (*Result, error) {
 
        if oldResult.IP6 != nil {
                newResult.IPs = append(newResult.IPs, &IPConfig{
-                       Version:   "6",
-                       Interface: -1,
-                       Address:   oldResult.IP6.IP,
-                       Gateway:   oldResult.IP6.Gateway,
+                       Version: "6",
+                       Address: oldResult.IP6.IP,
+                       Gateway: oldResult.IP6.Gateway,
                })
                for _, route := range oldResult.IP6.Routes {
                        gw := route.GW
@@ -117,6 +116,7 @@ func convertFrom030(result types.Result) (*Result, error) {
        if !ok {
                return nil, fmt.Errorf("failed to convert result")
        }
+       newResult.CNIVersion = ImplementedSpecVersion
        return newResult, nil
 }
 
@@ -134,6 +134,7 @@ func NewResultFromResult(result types.Result) (*Result, error) {
 
 // Result is what gets returned from the plugin (via stdout) to the caller
 type Result struct {
+       CNIVersion string         `json:"cniVersion,omitempty"`
        Interfaces []*Interface   `json:"interfaces,omitempty"`
        IPs        []*IPConfig    `json:"ips,omitempty"`
        Routes     []*types.Route `json:"routes,omitempty"`
@@ -143,7 +144,8 @@ type Result struct {
 // Convert to the older 0.2.0 CNI spec Result type
 func (r *Result) convertTo020() (*types020.Result, error) {
        oldResult := &types020.Result{
-               DNS: r.DNS,
+               CNIVersion: types020.ImplementedSpecVersion,
+               DNS:        r.DNS,
        }
 
        for _, ip := range r.IPs {
@@ -189,12 +191,13 @@ func (r *Result) convertTo020() (*types020.Result, error) {
 }
 
 func (r *Result) Version() string {
-       return implementedSpecVersion
+       return ImplementedSpecVersion
 }
 
 func (r *Result) GetAsVersion(version string) (types.Result, error) {
        switch version {
-       case "0.3.0", implementedSpecVersion:
+       case "0.3.0", ImplementedSpecVersion:
+               r.CNIVersion = version
                return r, nil
        case types020.SupportedVersions[0], types020.SupportedVersions[1], types020.SupportedVersions[2]:
                return r.convertTo020()
@@ -244,12 +247,18 @@ func (i *Interface) String() string {
        return fmt.Sprintf("%+v", *i)
 }
 
+// Int returns a pointer to the int value passed in.  Used to
+// set the IPConfig.Interface field.
+func Int(v int) *int {
+       return &v
+}
+
 // IPConfig contains values necessary to configure an IP address on an interface
 type IPConfig struct {
        // IP version, either "4" or "6"
        Version string
        // Index into Result structs Interfaces list
-       Interface int
+       Interface *int
        Address   net.IPNet
        Gateway   net.IP
 }
@@ -261,7 +270,7 @@ func (i *IPConfig) String() string {
 // JSON (un)marshallable types
 type ipConfig struct {
        Version   string      `json:"version"`
-       Interface int         `json:"interface,omitempty"`
+       Interface *int        `json:"interface,omitempty"`
        Address   types.IPNet `json:"address"`
        Gateway   net.IP      `json:"gateway,omitempty"`
 }
index 3263015..6412756 100644 (file)
@@ -136,7 +136,11 @@ type Error struct {
 }
 
 func (e *Error) Error() string {
-       return e.Msg
+       details := ""
+       if e.Details != "" {
+               details = fmt.Sprintf("; %v", e.Details)
+       }
+       return fmt.Sprintf("%v%v", e.Msg, details)
 }
 
 func (e *Error) Print() error {