Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
convert IPs to []string
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed May 7, 2020
1 parent 3a364e4 commit 08afded
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions plugin/ipam/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ func (i *Ipam) Allocate(args *skel.CmdArgs) (types.Result, error) {
var ipnet *net.IPNet

if len(conf.IPs) == 1 {
ip := conf.IPs[0]
if ip.Version == "4" {
ipnet = &ip.Address
err = i.weave.ClaimIP(containerID, ipnet, false)
} else {
ip := net.ParseIP(conf.IPs[0]).To4()

if ip == nil {
return nil, errors.New("allocation of ipv6 addresses is not implemented")
}

ipnet := &net.IPNet{
IP: ip,
Mask: ip.DefaultMask(),
}

err = i.weave.ClaimIP(containerID, ipnet, false)
} else if conf.Subnet == "" {
ipnet, err = i.weave.AllocateIP(containerID, false)
} else {
Expand Down Expand Up @@ -80,10 +85,10 @@ func (i *Ipam) Release(args *skel.CmdArgs) error {
}

type ipamConf struct {
Subnet string `json:"subnet,omitempty"`
Gateway net.IP `json:"gateway,omitempty"`
Routes []*types.Route `json:"routes"`
IPs []*current.IPConfig `json:"ips,omitempty"`
Subnet string `json:"subnet,omitempty"`
Gateway net.IP `json:"gateway,omitempty"`
Routes []*types.Route `json:"routes"`
IPs []string `json:"ips,omitempty"`
}

type netConf struct {
Expand Down

0 comments on commit 08afded

Please sign in to comment.