summaryrefslogtreecommitdiff
path: root/vendor/github.com/containernetworking/cni/pkg/types
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-03-28 10:30:09 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-03-28 15:12:26 +0100
commita5443a532b0fc6bd787cbb472c0ad2f75447c9df (patch)
tree691ecc024dfedff5695e426a8f3a6c077cfc34b8 /vendor/github.com/containernetworking/cni/pkg/types
parente7a2eecf5f3975edfb92cd2cacff0d34ef45f808 (diff)
downloadpodman-a5443a532b0fc6bd787cbb472c0ad2f75447c9df.tar.gz
podman-a5443a532b0fc6bd787cbb472c0ad2f75447c9df.tar.bz2
podman-a5443a532b0fc6bd787cbb472c0ad2f75447c9df.zip
vendor buildah, image, storage, cni
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/containernetworking/cni/pkg/types')
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/020/types.go7
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/current/types.go23
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/types.go14
3 files changed, 25 insertions, 19 deletions
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
index 2833aba78..53256167f 100644
--- a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
+++ b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
@@ -17,6 +17,7 @@ package types020
import (
"encoding/json"
"fmt"
+ "io"
"net"
"os"
@@ -73,11 +74,15 @@ func (r *Result) GetAsVersion(version string) (types.Result, error) {
}
func (r *Result) Print() error {
+ return r.PrintTo(os.Stdout)
+}
+
+func (r *Result) PrintTo(writer io.Writer) error {
data, err := json.MarshalIndent(r, "", " ")
if err != nil {
return err
}
- _, err = os.Stdout.Write(data)
+ _, err = writer.Write(data)
return err
}
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go b/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
index 92980c1a7..7267a2e6d 100644
--- a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
+++ b/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
@@ -17,6 +17,7 @@ package current
import (
"encoding/json"
"fmt"
+ "io"
"net"
"os"
@@ -75,13 +76,9 @@ func convertFrom020(result types.Result) (*Result, error) {
Gateway: oldResult.IP4.Gateway,
})
for _, route := range oldResult.IP4.Routes {
- gw := route.GW
- if gw == nil {
- gw = oldResult.IP4.Gateway
- }
newResult.Routes = append(newResult.Routes, &types.Route{
Dst: route.Dst,
- GW: gw,
+ GW: route.GW,
})
}
}
@@ -93,21 +90,13 @@ func convertFrom020(result types.Result) (*Result, error) {
Gateway: oldResult.IP6.Gateway,
})
for _, route := range oldResult.IP6.Routes {
- gw := route.GW
- if gw == nil {
- gw = oldResult.IP6.Gateway
- }
newResult.Routes = append(newResult.Routes, &types.Route{
Dst: route.Dst,
- GW: gw,
+ GW: route.GW,
})
}
}
- if len(newResult.IPs) == 0 {
- return nil, fmt.Errorf("cannot convert: no valid IP addresses")
- }
-
return newResult, nil
}
@@ -206,11 +195,15 @@ func (r *Result) GetAsVersion(version string) (types.Result, error) {
}
func (r *Result) Print() error {
+ return r.PrintTo(os.Stdout)
+}
+
+func (r *Result) PrintTo(writer io.Writer) error {
data, err := json.MarshalIndent(r, "", " ")
if err != nil {
return err
}
- _, err = os.Stdout.Write(data)
+ _, err = writer.Write(data)
return err
}
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/types.go b/vendor/github.com/containernetworking/cni/pkg/types/types.go
index 4684a3207..d0d11006a 100644
--- a/vendor/github.com/containernetworking/cni/pkg/types/types.go
+++ b/vendor/github.com/containernetworking/cni/pkg/types/types.go
@@ -18,6 +18,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "io"
"net"
"os"
)
@@ -65,6 +66,9 @@ type NetConf struct {
Capabilities map[string]bool `json:"capabilities,omitempty"`
IPAM IPAM `json:"ipam,omitempty"`
DNS DNS `json:"dns"`
+
+ RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
+ PrevResult Result `json:"-"`
}
type IPAM struct {
@@ -75,15 +79,16 @@ type IPAM struct {
type NetConfList struct {
CNIVersion string `json:"cniVersion,omitempty"`
- Name string `json:"name,omitempty"`
- Plugins []*NetConf `json:"plugins,omitempty"`
+ Name string `json:"name,omitempty"`
+ DisableCheck bool `json:"disableCheck,omitempty"`
+ Plugins []*NetConf `json:"plugins,omitempty"`
}
type ResultFactoryFunc func([]byte) (Result, error)
// Result is an interface that provides the result of plugin execution
type Result interface {
- // The highest CNI specification result verison the result supports
+ // The highest CNI specification result version the result supports
// without having to convert
Version() string
@@ -94,6 +99,9 @@ type Result interface {
// Prints the result in JSON format to stdout
Print() error
+ // Prints the result in JSON format to provided writer
+ PrintTo(writer io.Writer) error
+
// Returns a JSON string representation of the result
String() string
}