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

Commit 08afded

Browse files
committed
convert IPs to []string
1 parent 3a364e4 commit 08afded

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

plugin/ipam/cni.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ func (i *Ipam) Allocate(args *skel.CmdArgs) (types.Result, error) {
3939
var ipnet *net.IPNet
4040

4141
if len(conf.IPs) == 1 {
42-
ip := conf.IPs[0]
43-
if ip.Version == "4" {
44-
ipnet = &ip.Address
45-
err = i.weave.ClaimIP(containerID, ipnet, false)
46-
} else {
42+
ip := net.ParseIP(conf.IPs[0]).To4()
43+
44+
if ip == nil {
4745
return nil, errors.New("allocation of ipv6 addresses is not implemented")
4846
}
47+
48+
ipnet := &net.IPNet{
49+
IP: ip,
50+
Mask: ip.DefaultMask(),
51+
}
52+
53+
err = i.weave.ClaimIP(containerID, ipnet, false)
4954
} else if conf.Subnet == "" {
5055
ipnet, err = i.weave.AllocateIP(containerID, false)
5156
} else {
@@ -80,10 +85,10 @@ func (i *Ipam) Release(args *skel.CmdArgs) error {
8085
}
8186

8287
type ipamConf struct {
83-
Subnet string `json:"subnet,omitempty"`
84-
Gateway net.IP `json:"gateway,omitempty"`
85-
Routes []*types.Route `json:"routes"`
86-
IPs []*current.IPConfig `json:"ips,omitempty"`
88+
Subnet string `json:"subnet,omitempty"`
89+
Gateway net.IP `json:"gateway,omitempty"`
90+
Routes []*types.Route `json:"routes"`
91+
IPs []string `json:"ips,omitempty"`
8792
}
8893

8994
type netConf struct {

0 commit comments

Comments
 (0)