diff --git a/plugins/ipam/static/README.md b/plugins/ipam/static/README.md index 329a955a..0c473d91 100644 --- a/plugins/ipam/static/README.md +++ b/plugins/ipam/static/README.md @@ -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") diff --git a/plugins/ipam/static/main.go b/plugins/ipam/static/main.go index e4267220..e079c8dc 100644 --- a/plugins/ipam/static/main.go +++ b/plugins/ipam/static/main.go @@ -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 } diff --git a/plugins/ipam/static/static_test.go b/plugins/ipam/static/static_test.go index 77d0ee6a..afc631dd 100644 --- a/plugins/ipam/static/static_test.go +++ b/plugins/ipam/static/static_test.go @@ -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