Incorporate Dan's comments.
This commit is contained in:
parent
cc3ad26691
commit
60a99ca331
@ -48,8 +48,7 @@ static IPAM is very simple IPAM plugin that assigns IPv4 and IPv6 addresses stat
|
||||
|
||||
The following [CNI_ARGS](https://github.com/containernetworking/cni/blob/master/SPEC.md#parameters) are supported:
|
||||
|
||||
* `IP`: request a specific IP address
|
||||
* `SUBNET`: request a specific subnet
|
||||
* `IP`: request a specific CIDR notation IP address
|
||||
* `GATEWAY`: request a specific gateway address
|
||||
|
||||
(example: CNI_ARGS="IP=10.10.0.1;SUBNET=10.10.0.0/24;GATEWAY=10.10.0.254")
|
||||
(example: CNI_ARGS="IP=10.10.0.1/24;GATEWAY=10.10.0.254")
|
||||
|
@ -45,8 +45,7 @@ type IPAMConfig struct {
|
||||
|
||||
type IPAMEnvArgs struct {
|
||||
types.CommonArgs
|
||||
IP net.IP `json:"ip,omitempty"`
|
||||
SUBNET types.UnmarshallableString `json:"subnet,omitempty"`
|
||||
IP types.UnmarshallableString `json:"ip,omitempty"`
|
||||
GATEWAY net.IP `json:"gateway,omitempty"`
|
||||
}
|
||||
|
||||
@ -116,13 +115,13 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
if e.IP != nil && e.SUBNET != "" {
|
||||
_, subnet, err := net.ParseCIDR(string(e.SUBNET))
|
||||
if e.IP != "" {
|
||||
ip, subnet, err := net.ParseCIDR(string(e.IP))
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("invalid CIDR %s: %s", e.SUBNET, err)
|
||||
return nil, "", fmt.Errorf("invalid CIDR %s: %s", e.IP, err)
|
||||
}
|
||||
|
||||
addr := Address{Address: net.IPNet{IP: e.IP, Mask: subnet.Mask}}
|
||||
addr := Address{Address: net.IPNet{IP: ip, Mask: subnet.Mask}}
|
||||
if e.GATEWAY != nil {
|
||||
addr.Gateway = e.GATEWAY
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ var _ = Describe("static Operations", func() {
|
||||
Netns: nspath,
|
||||
IfName: ifname,
|
||||
StdinData: []byte(conf),
|
||||
Args: "IP=10.10.0.1;SUBNET=10.10.0.0/24;GATEWAY=10.10.0.254",
|
||||
Args: "IP=10.10.0.1/24;GATEWAY=10.10.0.254",
|
||||
}
|
||||
|
||||
// Allocate the IP
|
||||
|
Loading…
x
Reference in New Issue
Block a user