types: make Result an interface and move existing Result to separate package
This commit is contained in:
@ -29,6 +29,7 @@ import (
|
||||
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
"github.com/coreos/go-systemd/activation"
|
||||
)
|
||||
|
||||
@ -50,7 +51,7 @@ func newDHCP() *DHCP {
|
||||
|
||||
// Allocate acquires an IP from a DHCP server for a specified container.
|
||||
// The acquired lease will be maintained until Release() is called.
|
||||
func (d *DHCP) Allocate(args *skel.CmdArgs, result *types.Result) error {
|
||||
func (d *DHCP) Allocate(args *skel.CmdArgs, result *current.Result) error {
|
||||
conf := types.NetConf{}
|
||||
if err := json.Unmarshal(args.StdinData, &conf); err != nil {
|
||||
return fmt.Errorf("error parsing netconf: %v", err)
|
||||
@ -70,7 +71,7 @@ func (d *DHCP) Allocate(args *skel.CmdArgs, result *types.Result) error {
|
||||
|
||||
d.setLease(args.ContainerID, conf.Name, l)
|
||||
|
||||
result.IP4 = &types.IPConfig{
|
||||
result.IP4 = ¤t.IPConfig{
|
||||
IP: *ipn,
|
||||
Gateway: l.Gateway(),
|
||||
Routes: l.Routes(),
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
"github.com/containernetworking/cni/pkg/version"
|
||||
)
|
||||
|
||||
@ -36,8 +36,8 @@ func main() {
|
||||
}
|
||||
|
||||
func cmdAdd(args *skel.CmdArgs) error {
|
||||
result := types.Result{}
|
||||
if err := rpcCall("DHCP.Allocate", args, &result); err != nil {
|
||||
result := ¤t.Result{}
|
||||
if err := rpcCall("DHCP.Allocate", args, result); err != nil {
|
||||
return err
|
||||
}
|
||||
return result.Print()
|
||||
|
Reference in New Issue
Block a user