Signed-off-by: allencloud <allen.sun@daocloud.io>
| ... | ... |
@@ -207,7 +207,7 @@ func (cli *NetworkCli) CmdNetworkInfo(chain string, args ...string) error {
|
| 207 | 207 |
} |
| 208 | 208 |
|
| 209 | 209 |
// Helper function to predict if a string is a name or id or partial-id |
| 210 |
-// This provides a best-effort mechanism to identify a id with the help of GET Filter APIs |
|
| 210 |
+// This provides a best-effort mechanism to identify an id with the help of GET Filter APIs |
|
| 211 | 211 |
// Being a UI, its most likely that name will be used by the user, which is used to lookup |
| 212 | 212 |
// the corresponding ID. If ID is not found, this function will assume that the passed string |
| 213 | 213 |
// is an ID by itself. |
| ... | ... |
@@ -287,7 +287,7 @@ func startTestDriver() error {
|
| 287 | 287 |
mux := http.NewServeMux() |
| 288 | 288 |
server := httptest.NewServer(mux) |
| 289 | 289 |
if server == nil {
|
| 290 |
- return fmt.Errorf("Failed to start a HTTP Server")
|
|
| 290 |
+ return fmt.Errorf("Failed to start an HTTP Server")
|
|
| 291 | 291 |
} |
| 292 | 292 |
|
| 293 | 293 |
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
| ... | ... |
@@ -62,13 +62,13 @@ type datastore struct {
|
| 62 | 62 |
sync.Mutex |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
-// KVObject is Key/Value interface used by objects to be part of the DataStore |
|
| 65 |
+// KVObject is Key/Value interface used by objects to be part of the DataStore |
|
| 66 | 66 |
type KVObject interface {
|
| 67 |
- // Key method lets an object to provide the Key to be used in KV Store |
|
| 67 |
+ // Key method lets an object provide the Key to be used in KV Store |
|
| 68 | 68 |
Key() []string |
| 69 |
- // KeyPrefix method lets an object to return immediate parent key that can be used for tree walk |
|
| 69 |
+ // KeyPrefix method lets an object return immediate parent key that can be used for tree walk |
|
| 70 | 70 |
KeyPrefix() []string |
| 71 |
- // Value method lets an object to marshal its content to be stored in the KV store |
|
| 71 |
+ // Value method lets an object marshal its content to be stored in the KV store |
|
| 72 | 72 |
Value() []byte |
| 73 | 73 |
// SetValue is used by the datastore to set the object's value when loaded from the data store. |
| 74 | 74 |
SetValue([]byte) error |
| ... | ... |
@@ -116,7 +116,7 @@ During registration, the remote driver will receive a POST message to the URL `/ |
| 116 | 116 |
|
| 117 | 117 |
### RequestPool |
| 118 | 118 |
|
| 119 |
-This API is for registering a address pool with the IPAM driver. Multiple identical calls must return the same result. |
|
| 119 |
+This API is for registering an address pool with the IPAM driver. Multiple identical calls must return the same result. |
|
| 120 | 120 |
It is the IPAM driver's responsibility to keep a reference count for the pool. |
| 121 | 121 |
|
| 122 | 122 |
```go |
| ... | ... |
@@ -115,7 +115,7 @@ type InterfaceNameInfo interface {
|
| 115 | 115 |
// JoinInfo represents a set of resources that the driver has the ability to provide during |
| 116 | 116 |
// join time. |
| 117 | 117 |
type JoinInfo interface {
|
| 118 |
- // InterfaceName returns a InterfaceNameInfo go interface to facilitate |
|
| 118 |
+ // InterfaceName returns an InterfaceNameInfo go interface to facilitate |
|
| 119 | 119 |
// setting the names for the interface. |
| 120 | 120 |
InterfaceName() InterfaceNameInfo |
| 121 | 121 |
|
| ... | ... |
@@ -31,7 +31,7 @@ func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error) {
|
| 31 | 31 |
if err != nil {
|
| 32 | 32 |
return "", fmt.Errorf("error occoured looking up the %s parent iface %s error: %s", ipvlanType, parent, err)
|
| 33 | 33 |
} |
| 34 |
- // Create a ipvlan link |
|
| 34 |
+ // Create an ipvlan link |
|
| 35 | 35 |
ipvlan := &netlink.IPVlan{
|
| 36 | 36 |
LinkAttrs: netlink.LinkAttrs{
|
| 37 | 37 |
Name: containerIfName, |
| ... | ... |
@@ -15,7 +15,7 @@ func TestValidateLink(t *testing.T) {
|
| 15 | 15 |
if ok := parentExists(validIface); !ok {
|
| 16 | 16 |
t.Fatalf("failed validating loopback %s", validIface)
|
| 17 | 17 |
} |
| 18 |
- // test a invalid parent interface validation |
|
| 18 |
+ // test an invalid parent interface validation |
|
| 19 | 19 |
if ok := parentExists(invalidIface); ok {
|
| 20 | 20 |
t.Fatalf("failed to invalidate interface %s", invalidIface)
|
| 21 | 21 |
} |
| ... | ... |
@@ -33,17 +33,17 @@ func TestValidateSubLink(t *testing.T) {
|
| 33 | 33 |
if err != nil {
|
| 34 | 34 |
t.Fatalf("failed subinterface validation: %v", err)
|
| 35 | 35 |
} |
| 36 |
- // test a invalid vid with a valid parent link |
|
| 36 |
+ // test an invalid vid with a valid parent link |
|
| 37 | 37 |
_, _, err = parseVlan(invalidSubIface1) |
| 38 | 38 |
if err == nil {
|
| 39 | 39 |
t.Fatalf("failed subinterface validation test: %s", invalidSubIface1)
|
| 40 | 40 |
} |
| 41 |
- // test a valid vid with a valid parent link with a invalid delimiter |
|
| 41 |
+ // test a valid vid with a valid parent link with an invalid delimiter |
|
| 42 | 42 |
_, _, err = parseVlan(invalidSubIface2) |
| 43 | 43 |
if err == nil {
|
| 44 | 44 |
t.Fatalf("failed subinterface validation test: %v", invalidSubIface2)
|
| 45 | 45 |
} |
| 46 |
- // test a invalid parent link with a valid vid |
|
| 46 |
+ // test an invalid parent link with a valid vid |
|
| 47 | 47 |
_, _, err = parseVlan(invalidSubIface3) |
| 48 | 48 |
if err == nil {
|
| 49 | 49 |
t.Fatalf("failed subinterface validation test: %v", invalidSubIface3)
|
| ... | ... |
@@ -15,7 +15,7 @@ func TestValidateLink(t *testing.T) {
|
| 15 | 15 |
if ok := parentExists(validIface); !ok {
|
| 16 | 16 |
t.Fatalf("failed validating loopback %s", validIface)
|
| 17 | 17 |
} |
| 18 |
- // test a invalid parent interface validation |
|
| 18 |
+ // test an invalid parent interface validation |
|
| 19 | 19 |
if ok := parentExists(invalidIface); ok {
|
| 20 | 20 |
t.Fatalf("failed to invalidate interface %s", invalidIface)
|
| 21 | 21 |
} |
| ... | ... |
@@ -33,17 +33,17 @@ func TestValidateSubLink(t *testing.T) {
|
| 33 | 33 |
if err != nil {
|
| 34 | 34 |
t.Fatalf("failed subinterface validation: %v", err)
|
| 35 | 35 |
} |
| 36 |
- // test a invalid vid with a valid parent link |
|
| 36 |
+ // test an invalid vid with a valid parent link |
|
| 37 | 37 |
_, _, err = parseVlan(invalidSubIface1) |
| 38 | 38 |
if err == nil {
|
| 39 | 39 |
t.Fatalf("failed subinterface validation test: %s", invalidSubIface1)
|
| 40 | 40 |
} |
| 41 |
- // test a valid vid with a valid parent link with a invalid delimiter |
|
| 41 |
+ // test a valid vid with a valid parent link with an invalid delimiter |
|
| 42 | 42 |
_, _, err = parseVlan(invalidSubIface2) |
| 43 | 43 |
if err == nil {
|
| 44 | 44 |
t.Fatalf("failed subinterface validation test: %v", invalidSubIface2)
|
| 45 | 45 |
} |
| 46 |
- // test a invalid parent link with a valid vid |
|
| 46 |
+ // test an invalid parent link with a valid vid |
|
| 47 | 47 |
_, _, err = parseVlan(invalidSubIface3) |
| 48 | 48 |
if err == nil {
|
| 49 | 49 |
t.Fatalf("failed subinterface validation test: %v", invalidSubIface3)
|
| ... | ... |
@@ -46,7 +46,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
| 46 | 46 |
|
| 47 | 47 |
server := httptest.NewServer(mux) |
| 48 | 48 |
if server == nil {
|
| 49 |
- t.Fatal("Failed to start a HTTP Server")
|
|
| 49 |
+ t.Fatal("Failed to start an HTTP Server")
|
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
if err := ioutil.WriteFile(fmt.Sprintf("/etc/docker/plugins/%s.spec", name), []byte(server.URL), 0644); err != nil {
|
| ... | ... |
@@ -30,7 +30,7 @@ func TestDiff(t *testing.T) {
|
| 30 | 30 |
updated = mapset.NewSetFromSlice([]interface{}{addedIP})
|
| 31 | 31 |
added, removed = diff(existing, updated) |
| 32 | 32 |
if len(removed) != 2 {
|
| 33 |
- t.Fatalf("Diff failed for an remove update. Expecting 2 element, but got %d elements", len(removed))
|
|
| 33 |
+ t.Fatalf("Diff failed for a remove update. Expecting 2 element, but got %d elements", len(removed))
|
|
| 34 | 34 |
} |
| 35 | 35 |
if len(added) != 1 {
|
| 36 | 36 |
t.Fatalf("Diff failed for add use-case. Expecting 1 element, but got %d elements", len(added))
|
| ... | ... |
@@ -46,7 +46,7 @@ func TestAddedCallback(t *testing.T) {
|
| 46 | 46 |
removed := false |
| 47 | 47 |
hd.processCallback(update, func() {}, func(hosts []net.IP) { added = true }, func(hosts []net.IP) { removed = true })
|
| 48 | 48 |
if !added {
|
| 49 |
- t.Fatalf("Expecting a Added callback notification. But none received")
|
|
| 49 |
+ t.Fatalf("Expecting an Added callback notification. But none received")
|
|
| 50 | 50 |
} |
| 51 | 51 |
} |
| 52 | 52 |
|
| ... | ... |
@@ -27,7 +27,7 @@ const ( |
| 27 | 27 |
type Callback interface {
|
| 28 | 28 |
// RegisterIpamDriver provides a way for Remote drivers to dynamically register with libnetwork |
| 29 | 29 |
RegisterIpamDriver(name string, driver Ipam) error |
| 30 |
- // RegisterIpamDriverWithCapabilities provides a way for Remote drivers to dynamically register with libnetwork and specify cpaabilities |
|
| 30 |
+ // RegisterIpamDriverWithCapabilities provides a way for Remote drivers to dynamically register with libnetwork and specify capabilities |
|
| 31 | 31 |
RegisterIpamDriverWithCapabilities(name string, driver Ipam, capability *Capability) error |
| 32 | 32 |
} |
| 33 | 33 |
|
| ... | ... |
@@ -42,7 +42,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
| 42 | 42 |
|
| 43 | 43 |
server := httptest.NewServer(mux) |
| 44 | 44 |
if server == nil {
|
| 45 |
- t.Fatal("Failed to start a HTTP Server")
|
|
| 45 |
+ t.Fatal("Failed to start an HTTP Server")
|
|
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 | 48 |
if err := ioutil.WriteFile(fmt.Sprintf("/etc/docker/plugins/%s.spec", name), []byte(server.URL), 0644); err != nil {
|
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-// Package ipamutils provides utililty functions for ipam management |
|
| 1 |
+// Package ipamutils provides utility functions for ipam management |
|
| 2 | 2 |
package ipamutils |
| 3 | 3 |
|
| 4 | 4 |
import ( |
| ... | ... |
@@ -17,7 +17,7 @@ var ( |
| 17 | 17 |
initNetworksOnce sync.Once |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 |
-// InitNetworks initializes the pre-defined networks used by the built-in IP allocator |
|
| 20 |
+// InitNetworks initializes the pre-defined networks used by the built-in IP allocator |
|
| 21 | 21 |
func InitNetworks() {
|
| 22 | 22 |
initNetworksOnce.Do(func() {
|
| 23 | 23 |
PredefinedBroadNetworks = initBroadPredefinedNetworks() |
| ... | ... |
@@ -94,7 +94,7 @@ func (i *Handle) DelService(s *Service) error {
|
| 94 | 94 |
return i.doCmd(s, nil, ipvsCmdDelService) |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 |
-// NewDestination creates an new real server in the passed ipvs |
|
| 97 |
+// NewDestination creates a new real server in the passed ipvs |
|
| 98 | 98 |
// service which should already be existing in the passed handle. |
| 99 | 99 |
func (i *Handle) NewDestination(s *Service, d *Destination) error {
|
| 100 | 100 |
return i.doCmd(s, d, ipvsCmdNewDest) |
| ... | ... |
@@ -1115,7 +1115,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1115 | 1115 |
} |
| 1116 | 1116 |
|
| 1117 | 1117 |
if info.Sandbox() == nil {
|
| 1118 |
- t.Fatalf("Expected an non-empty sandbox key for a joined endpoint. Instead found a empty sandbox key")
|
|
| 1118 |
+ t.Fatalf("Expected a non-empty sandbox key for a joined endpoint. Instead found an empty sandbox key")
|
|
| 1119 | 1119 |
} |
| 1120 | 1120 |
|
| 1121 | 1121 |
// Check endpoint provided container information |
| ... | ... |
@@ -1314,7 +1314,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1314 | 1314 |
t.Fatalf("SetExternalKey must fail if the corresponding namespace is not created")
|
| 1315 | 1315 |
} |
| 1316 | 1316 |
} else {
|
| 1317 |
- // Setting an non-existing key (namespace) must fail |
|
| 1317 |
+ // Setting a non-existing key (namespace) must fail |
|
| 1318 | 1318 |
if err := sbox.SetKey("this-must-fail"); err == nil {
|
| 1319 | 1319 |
t.Fatalf("Setkey must fail if the corresponding namespace is not created")
|
| 1320 | 1320 |
} |
| ... | ... |
@@ -2018,7 +2018,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
| 2018 | 2018 |
mux := http.NewServeMux() |
| 2019 | 2019 |
server := httptest.NewServer(mux) |
| 2020 | 2020 |
if server == nil {
|
| 2021 |
- t.Fatal("Failed to start a HTTP Server")
|
|
| 2021 |
+ t.Fatal("Failed to start an HTTP Server")
|
|
| 2022 | 2022 |
} |
| 2023 | 2023 |
defer server.Close() |
| 2024 | 2024 |
|
| ... | ... |
@@ -2069,7 +2069,7 @@ func TestValidRemoteDriver(t *testing.T) {
|
| 2069 | 2069 |
mux := http.NewServeMux() |
| 2070 | 2070 |
server := httptest.NewServer(mux) |
| 2071 | 2071 |
if server == nil {
|
| 2072 |
- t.Fatal("Failed to start a HTTP Server")
|
|
| 2072 |
+ t.Fatal("Failed to start an HTTP Server")
|
|
| 2073 | 2073 |
} |
| 2074 | 2074 |
defer server.Close() |
| 2075 | 2075 |
|
| ... | ... |
@@ -170,7 +170,7 @@ func ReverseIP(IP string) string {
|
| 170 | 170 |
return strings.Join(reverseIP, ".") |
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 |
-// ParseAlias parses and validates the specified string as a alias format (name:alias) |
|
| 173 |
+// ParseAlias parses and validates the specified string as an alias format (name:alias) |
|
| 174 | 174 |
func ParseAlias(val string) (string, string, error) {
|
| 175 | 175 |
if val == "" {
|
| 176 | 176 |
return "", "", fmt.Errorf("empty string specified for alias")
|
| ... | ... |
@@ -1141,7 +1141,7 @@ func (n *network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPo |
| 1141 | 1141 |
} |
| 1142 | 1142 |
|
| 1143 | 1143 |
// If the network belongs to global scope or the pool was |
| 1144 |
- // explicitely chosen or it is invalid, do not perform the overlap check. |
|
| 1144 |
+ // explicitly chosen or it is invalid, do not perform the overlap check. |
|
| 1145 | 1145 |
if n.Scope() == datastore.GlobalScope || preferredPool != "" || !types.IsIPNetValid(pool) {
|
| 1146 | 1146 |
return poolID, pool, meta, nil |
| 1147 | 1147 |
} |
| ... | ... |
@@ -1165,7 +1165,7 @@ func (n *network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPo |
| 1165 | 1165 |
}() |
| 1166 | 1166 |
|
| 1167 | 1167 |
// If this is a preferred pool request and the network |
| 1168 |
- // is local scope and there is a overlap, we fail the |
|
| 1168 |
+ // is local scope and there is an overlap, we fail the |
|
| 1169 | 1169 |
// network creation right here. The pool will be |
| 1170 | 1170 |
// released in the defer. |
| 1171 | 1171 |
if preferredPool != "" {
|
| ... | ... |
@@ -41,7 +41,7 @@ func (e TypeMismatchError) Error() string {
|
| 41 | 41 |
return fmt.Sprintf("type mismatch, field %s require type %v, actual type %v", e.Field, e.ExpectType, e.ActualType)
|
| 42 | 42 |
} |
| 43 | 43 |
|
| 44 |
-// Generic is an basic type to store arbitrary settings. |
|
| 44 |
+// Generic is a basic type to store arbitrary settings. |
|
| 45 | 45 |
type Generic map[string]interface{}
|
| 46 | 46 |
|
| 47 | 47 |
// NewGeneric returns a new Generic instance. |
| ... | ... |
@@ -225,7 +225,7 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, rmService bool) {
|
| 225 | 225 |
func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, addService bool) {
|
| 226 | 226 |
i, err := ipvs.New(sb.Key()) |
| 227 | 227 |
if err != nil {
|
| 228 |
- logrus.Errorf("Failed to create a ipvs handle for sbox %s: %v", sb.Key(), err)
|
|
| 228 |
+ logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err)
|
|
| 229 | 229 |
return |
| 230 | 230 |
} |
| 231 | 231 |
defer i.Close() |
| ... | ... |
@@ -267,7 +267,7 @@ func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, addService bool) |
| 267 | 267 |
func (sb *sandbox) rmLBBackend(ip, vip net.IP, fwMark uint32, rmService bool) {
|
| 268 | 268 |
i, err := ipvs.New(sb.Key()) |
| 269 | 269 |
if err != nil {
|
| 270 |
- logrus.Errorf("Failed to create a ipvs handle for sbox %s: %v", sb.Key(), err)
|
|
| 270 |
+ logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err)
|
|
| 271 | 271 |
return |
| 272 | 272 |
} |
| 273 | 273 |
defer i.Close() |