| 1 | // Copyright 2016 CNI authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package allocatorscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/ |
| 16 | |
| 17 | import ( |
| 18 | "netscip-go gomod github.com/golang/go/src go1.24.2 net/" |
| 19 | |
| 20 | . "github.com/onsi/ginkgo/v2scip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/" |
| 21 | . "github.com/onsi/gomegascip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/" |
| 22 | |
| 23 | "github.com/containernetworking/cni/pkg/typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/" |
| 24 | ) |
| 25 | |
| 26 | var _ = Describescip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Describe().("IPAM config", func() { |
| 27 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should parse an old-style config", func() { |
| 28 | input := `{ |
| 29 | "cniVersion": "0.3.1", |
| 30 | "name": "mynet", |
| 31 | "type": "ipvlan", |
| 32 | "master": "foo0", |
| 33 | "ipam": { |
| 34 | "type": "host-local", |
| 35 | "subnet": "10.1.2.0/24", |
| 36 | "rangeStart": "10.1.2.9", |
| 37 | "rangeEnd": "10.1.2.20", |
| 38 | "gateway": "10.1.2.30" |
| 39 | } |
| 40 | }` |
| 41 | conf, version, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 42 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 43 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(version).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#Should().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().("0.3.1")) |
| 44 | |
| 45 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(&IPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#{ |
| 46 | Namescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Name.: "mynet", |
| 47 | Typescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Type.: "host-local", |
| 48 | Rangesscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Ranges.: []RangeSetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/RangeSet#{ |
| 49 | { |
| 50 | { |
| 51 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 9}, |
| 52 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 20}, |
| 53 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 30}, |
| 54 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 55 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 0}, |
| 56 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | }, |
| 61 | })) |
| 62 | }) |
| 63 | |
| 64 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should parse a new-style config", func() { |
| 65 | input := `{ |
| 66 | "cniVersion": "0.3.1", |
| 67 | "name": "mynet", |
| 68 | "type": "ipvlan", |
| 69 | "master": "foo0", |
| 70 | "ipam": { |
| 71 | "type": "host-local", |
| 72 | "ranges": [ |
| 73 | [ |
| 74 | { |
| 75 | "subnet": "10.1.2.0/24", |
| 76 | "rangeStart": "10.1.2.9", |
| 77 | "rangeEnd": "10.1.2.20", |
| 78 | "gateway": "10.1.2.30" |
| 79 | }, |
| 80 | { |
| 81 | "subnet": "10.1.4.0/24" |
| 82 | } |
| 83 | ], |
| 84 | [{ |
| 85 | "subnet": "11.1.2.0/24", |
| 86 | "rangeStart": "11.1.2.9", |
| 87 | "rangeEnd": "11.1.2.20", |
| 88 | "gateway": "11.1.2.30" |
| 89 | }] |
| 90 | ] |
| 91 | } |
| 92 | }` |
| 93 | conf, version, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 94 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 95 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(version).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#Should().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().("0.3.1")) |
| 96 | |
| 97 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(&IPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#{ |
| 98 | Namescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Name.: "mynet", |
| 99 | Typescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Type.: "host-local", |
| 100 | Rangesscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Ranges.: []RangeSetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/RangeSet#{ |
| 101 | { |
| 102 | { |
| 103 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 9}, |
| 104 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 20}, |
| 105 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 30}, |
| 106 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 107 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 0}, |
| 108 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 109 | }, |
| 110 | }, |
| 111 | { |
| 112 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 4, 1}, |
| 113 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 4, 254}, |
| 114 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 4, 1}, |
| 115 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 116 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 4, 0}, |
| 117 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 118 | }, |
| 119 | }, |
| 120 | }, |
| 121 | { |
| 122 | { |
| 123 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 9}, |
| 124 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 20}, |
| 125 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 30}, |
| 126 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 127 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 0}, |
| 128 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 129 | }, |
| 130 | }, |
| 131 | }, |
| 132 | }, |
| 133 | })) |
| 134 | }) |
| 135 | |
| 136 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should parse a mixed config with runtime args", func() { |
| 137 | input := `{ |
| 138 | "cniVersion": "0.3.1", |
| 139 | "name": "mynet", |
| 140 | "type": "ipvlan", |
| 141 | "master": "foo0", |
| 142 | "runtimeConfig": { |
| 143 | "irrelevant": "a", |
| 144 | "ipRanges": [ |
| 145 | [{ "subnet": "12.1.3.0/24" }] |
| 146 | ] |
| 147 | }, |
| 148 | "ipam": { |
| 149 | "type": "host-local", |
| 150 | "subnet": "10.1.2.0/24", |
| 151 | "rangeStart": "10.1.2.9", |
| 152 | "rangeEnd": "10.1.2.20", |
| 153 | "gateway": "10.1.2.30", |
| 154 | "ranges": [[ |
| 155 | { |
| 156 | "subnet": "11.1.2.0/24", |
| 157 | "rangeStart": "11.1.2.9", |
| 158 | "rangeEnd": "11.1.2.20", |
| 159 | "gateway": "11.1.2.30" |
| 160 | } |
| 161 | ]] |
| 162 | } |
| 163 | }` |
| 164 | conf, version, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 165 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 166 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(version).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#Should().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().("0.3.1")) |
| 167 | |
| 168 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().(&IPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#{ |
| 169 | Namescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Name.: "mynet", |
| 170 | Typescip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Type.: "host-local", |
| 171 | Rangesscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#Ranges.: []RangeSetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/RangeSet#{ |
| 172 | { // The RuntimeConfig should always be first |
| 173 | { |
| 174 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{12, 1, 3, 1}, |
| 175 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{12, 1, 3, 254}, |
| 176 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{12, 1, 3, 1}, |
| 177 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 178 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{12, 1, 3, 0}, |
| 179 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 180 | }, |
| 181 | }, |
| 182 | }, |
| 183 | { |
| 184 | { |
| 185 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 9}, |
| 186 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 20}, |
| 187 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 30}, |
| 188 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 189 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{10, 1, 2, 0}, |
| 190 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 191 | }, |
| 192 | }, |
| 193 | }, |
| 194 | { |
| 195 | { |
| 196 | RangeStartscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeStart.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 9}, |
| 197 | RangeEndscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#RangeEnd.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 20}, |
| 198 | Gatewayscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Gateway.: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 30}, |
| 199 | Subnetscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/Range#Subnet.: typesscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/.IPNetscip-go gomod github.com/containernetworking/cni v1.3.0 `github.com/containernetworking/cni/pkg/types`/IPNet#{ |
| 200 | IP: netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{11, 1, 2, 0}, |
| 201 | Mask: netscip-go gomod github.com/golang/go/src go1.24.2 net/.CIDRMaskscip-go gomod github.com/golang/go/src go1.24.2 net/CIDRMask().(24, 32), |
| 202 | }, |
| 203 | }, |
| 204 | }, |
| 205 | }, |
| 206 | })) |
| 207 | }) |
| 208 | |
| 209 | Contextscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Context.("Should parse CNI_ARGS env", func() { |
| 210 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("without prefix", func() { |
| 211 | input := `{ |
| 212 | "cniVersion": "0.3.1", |
| 213 | "name": "mynet", |
| 214 | "type": "ipvlan", |
| 215 | "master": "foo0", |
| 216 | "ipam": { |
| 217 | "type": "host-local", |
| 218 | "ranges": [[ |
| 219 | { |
| 220 | "subnet": "10.1.2.0/24", |
| 221 | "rangeStart": "10.1.2.9", |
| 222 | "rangeEnd": "10.1.2.20", |
| 223 | "gateway": "10.1.2.30" |
| 224 | } |
| 225 | ]] |
| 226 | } |
| 227 | }` |
| 228 | |
| 229 | envArgs := "IP=10.1.2.10" |
| 230 | |
| 231 | conf, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), envArgs) |
| 232 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 233 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf.IPArgsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#IPArgs.).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().([]netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{{10, 1, 2, 10}})) |
| 234 | }) |
| 235 | |
| 236 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("with prefix", func() { |
| 237 | input := `{ |
| 238 | "cniVersion": "0.3.1", |
| 239 | "name": "mynet", |
| 240 | "type": "ipvlan", |
| 241 | "master": "foo0", |
| 242 | "ipam": { |
| 243 | "type": "host-local", |
| 244 | "ranges": [[ |
| 245 | { |
| 246 | "subnet": "10.1.2.0/24", |
| 247 | "rangeStart": "10.1.2.9", |
| 248 | "rangeEnd": "10.1.2.20", |
| 249 | "gateway": "10.1.2.30" |
| 250 | } |
| 251 | ]] |
| 252 | } |
| 253 | }` |
| 254 | |
| 255 | envArgs := "IP=10.1.2.11/24" |
| 256 | |
| 257 | conf, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), envArgs) |
| 258 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 259 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf.IPArgsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#IPArgs.).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().([]netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{{10, 1, 2, 11}})) |
| 260 | }) |
| 261 | }) |
| 262 | |
| 263 | Contextscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/Context.("Should parse config args", func() { |
| 264 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("without prefix", func() { |
| 265 | input := `{ |
| 266 | "cniVersion": "0.3.1", |
| 267 | "name": "mynet", |
| 268 | "type": "ipvlan", |
| 269 | "master": "foo0", |
| 270 | "args": { |
| 271 | "cni": { |
| 272 | "ips": [ "10.1.2.11", "11.11.11.11", "2001:db8:1::11"] |
| 273 | } |
| 274 | }, |
| 275 | "ipam": { |
| 276 | "type": "host-local", |
| 277 | "ranges": [ |
| 278 | [{ |
| 279 | "subnet": "10.1.2.0/24", |
| 280 | "rangeStart": "10.1.2.9", |
| 281 | "rangeEnd": "10.1.2.20", |
| 282 | "gateway": "10.1.2.30" |
| 283 | }], |
| 284 | [{ |
| 285 | "subnet": "11.1.2.0/24", |
| 286 | "rangeStart": "11.1.2.9", |
| 287 | "rangeEnd": "11.1.2.20", |
| 288 | "gateway": "11.1.2.30" |
| 289 | }], |
| 290 | [{ |
| 291 | "subnet": "2001:db8:1::/64" |
| 292 | }] |
| 293 | ] |
| 294 | } |
| 295 | }` |
| 296 | |
| 297 | envArgs := "IP=10.1.2.10" |
| 298 | |
| 299 | conf, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), envArgs) |
| 300 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 301 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf.IPArgsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#IPArgs.).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().([]netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{ |
| 302 | {10, 1, 2, 10}, |
| 303 | {10, 1, 2, 11}, |
| 304 | {11, 11, 11, 11}, |
| 305 | netscip-go gomod github.com/golang/go/src go1.24.2 net/.ParseIPscip-go gomod github.com/golang/go/src go1.24.2 net/ParseIP().("2001:db8:1::11"), |
| 306 | })) |
| 307 | }) |
| 308 | |
| 309 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("with prefix", func() { |
| 310 | input := `{ |
| 311 | "cniVersion": "0.3.1", |
| 312 | "name": "mynet", |
| 313 | "type": "ipvlan", |
| 314 | "master": "foo0", |
| 315 | "args": { |
| 316 | "cni": { |
| 317 | "ips": [ "10.1.2.11/24", "11.11.11.11/24", "2001:db8:1::11/64"] |
| 318 | } |
| 319 | }, |
| 320 | "ipam": { |
| 321 | "type": "host-local", |
| 322 | "ranges": [ |
| 323 | [{ |
| 324 | "subnet": "10.1.2.0/24", |
| 325 | "rangeStart": "10.1.2.9", |
| 326 | "rangeEnd": "10.1.2.20", |
| 327 | "gateway": "10.1.2.30" |
| 328 | }], |
| 329 | [{ |
| 330 | "subnet": "11.1.2.0/24", |
| 331 | "rangeStart": "11.1.2.9", |
| 332 | "rangeEnd": "11.1.2.20", |
| 333 | "gateway": "11.1.2.30" |
| 334 | }], |
| 335 | [{ |
| 336 | "subnet": "2001:db8:1::/64" |
| 337 | }] |
| 338 | ] |
| 339 | } |
| 340 | }` |
| 341 | |
| 342 | envArgs := "IP=10.1.2.10/24" |
| 343 | |
| 344 | conf, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), envArgs) |
| 345 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 346 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf.IPArgsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#IPArgs.).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().([]netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{ |
| 347 | {10, 1, 2, 10}, |
| 348 | {10, 1, 2, 11}, |
| 349 | {11, 11, 11, 11}, |
| 350 | netscip-go gomod github.com/golang/go/src go1.24.2 net/.ParseIPscip-go gomod github.com/golang/go/src go1.24.2 net/ParseIP().("2001:db8:1::11"), |
| 351 | })) |
| 352 | }) |
| 353 | }) |
| 354 | |
| 355 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should detect overlap between rangesets", func() { |
| 356 | input := `{ |
| 357 | "cniVersion": "0.3.1", |
| 358 | "name": "mynet", |
| 359 | "type": "ipvlan", |
| 360 | "master": "foo0", |
| 361 | "ipam": { |
| 362 | "type": "host-local", |
| 363 | "ranges": [ |
| 364 | [ |
| 365 | {"subnet": "10.1.2.0/24"}, |
| 366 | {"subnet": "10.2.2.0/24"} |
| 367 | ], |
| 368 | [ |
| 369 | { "subnet": "10.1.4.0/24"}, |
| 370 | { "subnet": "10.1.6.0/24"}, |
| 371 | { "subnet": "10.1.8.0/24"}, |
| 372 | { "subnet": "10.1.2.0/24"} |
| 373 | ] |
| 374 | ] |
| 375 | } |
| 376 | }` |
| 377 | _, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 378 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(MatchErrorscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/MatchError().("range set 0 overlaps with 1")) |
| 379 | }) |
| 380 | |
| 381 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should detect overlap within rangeset", func() { |
| 382 | input := `{ |
| 383 | "cniVersion": "0.3.1", |
| 384 | "name": "mynet", |
| 385 | "type": "ipvlan", |
| 386 | "master": "foo0", |
| 387 | "ipam": { |
| 388 | "type": "host-local", |
| 389 | "ranges": [ |
| 390 | [ |
| 391 | { "subnet": "10.1.0.0/22" }, |
| 392 | { "subnet": "10.1.2.0/24" } |
| 393 | ] |
| 394 | ] |
| 395 | } |
| 396 | }` |
| 397 | _, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 398 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(MatchErrorscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/MatchError().("invalid range set 0: subnets 10.1.0.1-10.1.3.254 and 10.1.2.1-10.1.2.254 overlap")) |
| 399 | }) |
| 400 | |
| 401 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("should error on rangesets with different families", func() { |
| 402 | input := `{ |
| 403 | "cniVersion": "0.3.1", |
| 404 | "name": "mynet", |
| 405 | "type": "ipvlan", |
| 406 | "master": "foo0", |
| 407 | "ipam": { |
| 408 | "type": "host-local", |
| 409 | "ranges": [ |
| 410 | [ |
| 411 | { "subnet": "10.1.0.0/22" }, |
| 412 | { "subnet": "2001:db8:5::/64" } |
| 413 | ] |
| 414 | ] |
| 415 | } |
| 416 | }` |
| 417 | _, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 418 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(MatchErrorscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/MatchError().("invalid range set 0: mixed address families")) |
| 419 | }) |
| 420 | |
| 421 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should should error on too many ranges", func() { |
| 422 | input := `{ |
| 423 | "cniVersion": "0.2.0", |
| 424 | "name": "mynet", |
| 425 | "type": "ipvlan", |
| 426 | "master": "foo0", |
| 427 | "ipam": { |
| 428 | "type": "host-local", |
| 429 | "ranges": [ |
| 430 | [{"subnet": "10.1.2.0/24"}], |
| 431 | [{"subnet": "11.1.2.0/24"}] |
| 432 | ] |
| 433 | } |
| 434 | }` |
| 435 | _, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 436 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(MatchErrorscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/MatchError().("CNI version 0.2.0 does not support more than 1 address per family")) |
| 437 | }) |
| 438 | |
| 439 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should allow one v4 and v6 range for 0.2.0", func() { |
| 440 | input := `{ |
| 441 | "cniVersion": "0.2.0", |
| 442 | "name": "mynet", |
| 443 | "type": "ipvlan", |
| 444 | "master": "foo0", |
| 445 | "ipam": { |
| 446 | "type": "host-local", |
| 447 | "ranges": [ |
| 448 | [{"subnet": "10.1.2.0/24"}], |
| 449 | [{"subnet": "2001:db8:1::/48"}] |
| 450 | ] |
| 451 | } |
| 452 | }` |
| 453 | _, _, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 454 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 455 | }) |
| 456 | |
| 457 | Itscip-go gomod github.com/onsi/ginkgo/v2 v2.25.1 `github.com/onsi/ginkgo/v2`/It().("Should parse custom IPs from runtime configuration", func() { |
| 458 | input := `{ |
| 459 | "cniVersion": "0.3.1", |
| 460 | "name": "mynet", |
| 461 | "type": "ipvlan", |
| 462 | "master": "foo0", |
| 463 | "runtimeConfig": { |
| 464 | "ips": ["192.168.0.1", "192.168.0.5/24", "2001:db8::1/64"] |
| 465 | }, |
| 466 | "ipam": { |
| 467 | "type": "host-local", |
| 468 | "subnet": "10.1.2.0/24" |
| 469 | } |
| 470 | }` |
| 471 | conf, version, err := LoadIPAMConfigscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/LoadIPAMConfig().([]byte(input), "") |
| 472 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(err).NotToscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#NotTo().(HaveOccurredscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/HaveOccurred().()) |
| 473 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(version).Shouldscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#Should().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().("0.3.1")) |
| 474 | |
| 475 | Expectscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Expect().(conf.IPArgsscip-go gomod github.com/containernetworking/plugins . `github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator`/IPAMConfig#IPArgs.).Toscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega/types`/Assertion#To().(Equalscip-go gomod github.com/onsi/gomega v1.38.1 `github.com/onsi/gomega`/Equal().([]netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPscip-go gomod github.com/golang/go/src go1.24.2 net/IP#{ |
| 476 | netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPv4scip-go gomod github.com/golang/go/src go1.24.2 net/IPv4().(192, 168, 0, 1).To4scip-go gomod github.com/golang/go/src go1.24.2 net/IP#To4().(), |
| 477 | netscip-go gomod github.com/golang/go/src go1.24.2 net/.IPv4scip-go gomod github.com/golang/go/src go1.24.2 net/IPv4().(192, 168, 0, 5).To4scip-go gomod github.com/golang/go/src go1.24.2 net/IP#To4().(), |
| 478 | netscip-go gomod github.com/golang/go/src go1.24.2 net/.ParseIPscip-go gomod github.com/golang/go/src go1.24.2 net/ParseIP().("2001:db8::1"), |
| 479 | })) |
| 480 | }) |
| 481 | }) |