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

Commit f906b0a

Browse files
committed
add support for ips in ipam config
1 parent 7c97bb5 commit f906b0a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

plugin/ipam/cni.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ipamplugin
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"net"
78

@@ -37,7 +38,15 @@ func (i *Ipam) Allocate(args *skel.CmdArgs) (types.Result, error) {
3738
}
3839
var ipnet *net.IPNet
3940

40-
if conf.Subnet == "" {
41+
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 {
47+
return nil, errors.New("Not Implemented")
48+
}
49+
} else if conf.Subnet == "" {
4150
ipnet, err = i.weave.AllocateIP(containerID, false)
4251
} else {
4352
var subnet *net.IPNet
@@ -71,9 +80,10 @@ func (i *Ipam) Release(args *skel.CmdArgs) error {
7180
}
7281

7382
type ipamConf struct {
74-
Subnet string `json:"subnet,omitempty"`
75-
Gateway net.IP `json:"gateway,omitempty"`
76-
Routes []*types.Route `json:"routes"`
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"`
7787
}
7888

7989
type netConf struct {

0 commit comments

Comments
 (0)