vendor: bump cni to 0.5.2-git49d814c

This commit is contained in:
Dan Williams
2017-06-22 09:44:41 -05:00
parent 5a7a8b3069
commit 121362601b
6 changed files with 67 additions and 53 deletions

28
Godeps/Godeps.json generated
View File

@ -8,38 +8,38 @@
"Deps": [ "Deps": [
{ {
"ImportPath": "github.com/containernetworking/cni/libcni", "ImportPath": "github.com/containernetworking/cni/libcni",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/containernetworking/cni/pkg/invoke", "ImportPath": "github.com/containernetworking/cni/pkg/invoke",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/containernetworking/cni/pkg/skel", "ImportPath": "github.com/containernetworking/cni/pkg/skel",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/containernetworking/cni/pkg/types", "ImportPath": "github.com/containernetworking/cni/pkg/types",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/containernetworking/cni/pkg/types/020", "ImportPath": "github.com/containernetworking/cni/pkg/types/020",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/containernetworking/cni/pkg/types/current", "ImportPath": "github.com/containernetworking/cni/pkg/types/current",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/containernetworking/cni/pkg/version", "ImportPath": "github.com/containernetworking/cni/pkg/version",
"Comment": "v0.5.2", "Comment": "v0.5.2-git49d814c",
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e" "Rev": "49d814cf37bfea351a1caedd0c66825c9d6fca52"
}, },
{ {
"ImportPath": "github.com/coreos/go-iptables/iptables", "ImportPath": "github.com/coreos/go-iptables/iptables",

View File

@ -57,13 +57,16 @@ func (args *Args) AsEnv() []string {
pluginArgsStr = stringify(args.PluginArgs) pluginArgsStr = stringify(args.PluginArgs)
} }
env = append(env, // 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_COMMAND=" + args.Command,
"CNI_CONTAINERID=" + args.ContainerID, "CNI_CONTAINERID=" + args.ContainerID,
"CNI_NETNS=" + args.NetNS, "CNI_NETNS=" + args.NetNS,
"CNI_ARGS=" + pluginArgsStr, "CNI_ARGS=" + pluginArgsStr,
"CNI_IFNAME=" + args.IfName, "CNI_IFNAME=" + args.IfName,
"CNI_PATH="+args.Path) "CNI_PATH=" + args.Path,
}, env...)
return env return env
} }

View File

@ -50,13 +50,9 @@ func pluginErr(err error, output []byte) error {
if _, ok := err.(*exec.ExitError); ok { if _, ok := err.(*exec.ExitError); ok {
emsg := types.Error{} emsg := types.Error{}
if perr := json.Unmarshal(output, &emsg); perr != nil { 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 := "" return &emsg
if emsg.Details != "" {
details = fmt.Sprintf("; %v", emsg.Details)
}
return fmt.Errorf("%v%v", emsg.Msg, details)
} }
return err return err

View File

@ -23,9 +23,9 @@ import (
"github.com/containernetworking/cni/pkg/types" "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 // 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) { func GetResult(r types.Result) (*Result, error) {
// We expect version 0.1.0/0.2.0 results // We expect version 0.1.0/0.2.0 results
result020, err := r.GetAsVersion(implementedSpecVersion) result020, err := r.GetAsVersion(ImplementedSpecVersion)
if err != nil { if err != nil {
return nil, err 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 // Result is what gets returned from the plugin (via stdout) to the caller
type Result struct { type Result struct {
CNIVersion string `json:"cniVersion,omitempty"`
IP4 *IPConfig `json:"ip4,omitempty"` IP4 *IPConfig `json:"ip4,omitempty"`
IP6 *IPConfig `json:"ip6,omitempty"` IP6 *IPConfig `json:"ip6,omitempty"`
DNS types.DNS `json:"dns,omitempty"` DNS types.DNS `json:"dns,omitempty"`
} }
func (r *Result) Version() string { func (r *Result) Version() string {
return implementedSpecVersion return ImplementedSpecVersion
} }
func (r *Result) GetAsVersion(version string) (types.Result, error) { func (r *Result) GetAsVersion(version string) (types.Result, error) {
for _, supportedVersion := range SupportedVersions { for _, supportedVersion := range SupportedVersions {
if version == supportedVersion { if version == supportedVersion {
r.CNIVersion = version
return r, nil return r, nil
} }
} }

View File

@ -24,9 +24,9 @@ import (
"github.com/containernetworking/cni/pkg/types/020" "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) { func NewResult(data []byte) (types.Result, error) {
result := &Result{} result := &Result{}
@ -37,7 +37,7 @@ func NewResult(data []byte) (types.Result, error) {
} }
func GetResult(r types.Result) (*Result, error) { func GetResult(r types.Result) (*Result, error) {
resultCurrent, err := r.GetAsVersion(implementedSpecVersion) resultCurrent, err := r.GetAsVersion(ImplementedSpecVersion)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -63,6 +63,7 @@ func convertFrom020(result types.Result) (*Result, error) {
} }
newResult := &Result{ newResult := &Result{
CNIVersion: ImplementedSpecVersion,
DNS: oldResult.DNS, DNS: oldResult.DNS,
Routes: []*types.Route{}, Routes: []*types.Route{},
} }
@ -70,7 +71,6 @@ func convertFrom020(result types.Result) (*Result, error) {
if oldResult.IP4 != nil { if oldResult.IP4 != nil {
newResult.IPs = append(newResult.IPs, &IPConfig{ newResult.IPs = append(newResult.IPs, &IPConfig{
Version: "4", Version: "4",
Interface: -1,
Address: oldResult.IP4.IP, Address: oldResult.IP4.IP,
Gateway: oldResult.IP4.Gateway, Gateway: oldResult.IP4.Gateway,
}) })
@ -89,7 +89,6 @@ func convertFrom020(result types.Result) (*Result, error) {
if oldResult.IP6 != nil { if oldResult.IP6 != nil {
newResult.IPs = append(newResult.IPs, &IPConfig{ newResult.IPs = append(newResult.IPs, &IPConfig{
Version: "6", Version: "6",
Interface: -1,
Address: oldResult.IP6.IP, Address: oldResult.IP6.IP,
Gateway: oldResult.IP6.Gateway, Gateway: oldResult.IP6.Gateway,
}) })
@ -117,6 +116,7 @@ func convertFrom030(result types.Result) (*Result, error) {
if !ok { if !ok {
return nil, fmt.Errorf("failed to convert result") return nil, fmt.Errorf("failed to convert result")
} }
newResult.CNIVersion = ImplementedSpecVersion
return newResult, nil 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 // Result is what gets returned from the plugin (via stdout) to the caller
type Result struct { type Result struct {
CNIVersion string `json:"cniVersion,omitempty"`
Interfaces []*Interface `json:"interfaces,omitempty"` Interfaces []*Interface `json:"interfaces,omitempty"`
IPs []*IPConfig `json:"ips,omitempty"` IPs []*IPConfig `json:"ips,omitempty"`
Routes []*types.Route `json:"routes,omitempty"` Routes []*types.Route `json:"routes,omitempty"`
@ -143,6 +144,7 @@ type Result struct {
// Convert to the older 0.2.0 CNI spec Result type // Convert to the older 0.2.0 CNI spec Result type
func (r *Result) convertTo020() (*types020.Result, error) { func (r *Result) convertTo020() (*types020.Result, error) {
oldResult := &types020.Result{ oldResult := &types020.Result{
CNIVersion: types020.ImplementedSpecVersion,
DNS: r.DNS, DNS: r.DNS,
} }
@ -189,12 +191,13 @@ func (r *Result) convertTo020() (*types020.Result, error) {
} }
func (r *Result) Version() string { func (r *Result) Version() string {
return implementedSpecVersion return ImplementedSpecVersion
} }
func (r *Result) GetAsVersion(version string) (types.Result, error) { func (r *Result) GetAsVersion(version string) (types.Result, error) {
switch version { switch version {
case "0.3.0", implementedSpecVersion: case "0.3.0", ImplementedSpecVersion:
r.CNIVersion = version
return r, nil return r, nil
case types020.SupportedVersions[0], types020.SupportedVersions[1], types020.SupportedVersions[2]: case types020.SupportedVersions[0], types020.SupportedVersions[1], types020.SupportedVersions[2]:
return r.convertTo020() return r.convertTo020()
@ -244,12 +247,18 @@ func (i *Interface) String() string {
return fmt.Sprintf("%+v", *i) 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 // IPConfig contains values necessary to configure an IP address on an interface
type IPConfig struct { type IPConfig struct {
// IP version, either "4" or "6" // IP version, either "4" or "6"
Version string Version string
// Index into Result structs Interfaces list // Index into Result structs Interfaces list
Interface int Interface *int
Address net.IPNet Address net.IPNet
Gateway net.IP Gateway net.IP
} }
@ -261,7 +270,7 @@ func (i *IPConfig) String() string {
// JSON (un)marshallable types // JSON (un)marshallable types
type ipConfig struct { type ipConfig struct {
Version string `json:"version"` Version string `json:"version"`
Interface int `json:"interface,omitempty"` Interface *int `json:"interface,omitempty"`
Address types.IPNet `json:"address"` Address types.IPNet `json:"address"`
Gateway net.IP `json:"gateway,omitempty"` Gateway net.IP `json:"gateway,omitempty"`
} }

View File

@ -136,7 +136,11 @@ type Error struct {
} }
func (e *Error) Error() string { 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 { func (e *Error) Print() error {