use grep to find a/an misuse
Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
parent
2dd111e74c
commit
9f415d0cdb
21 changed files with 37 additions and 37 deletions
|
@ -2304,7 +2304,7 @@ func (nip *notimpl) NotImplemented() {}
|
|||
type inter struct{}
|
||||
|
||||
func (it *inter) Error() string {
|
||||
return "I am a internal error"
|
||||
return "I am an internal error"
|
||||
}
|
||||
func (it *inter) Internal() {}
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ func (cli *NetworkCli) CmdNetworkInfo(chain string, args ...string) error {
|
|||
}
|
||||
|
||||
// Helper function to predict if a string is a name or id or partial-id
|
||||
// This provides a best-effort mechanism to identify a id with the help of GET Filter APIs
|
||||
// This provides a best-effort mechanism to identify an id with the help of GET Filter APIs
|
||||
// Being a UI, its most likely that name will be used by the user, which is used to lookup
|
||||
// the corresponding ID. If ID is not found, this function will assume that the passed string
|
||||
// is an ID by itself.
|
||||
|
|
|
@ -287,7 +287,7 @@ func startTestDriver() error {
|
|||
mux := http.NewServeMux()
|
||||
server := httptest.NewServer(mux)
|
||||
if server == nil {
|
||||
return fmt.Errorf("Failed to start a HTTP Server")
|
||||
return fmt.Errorf("Failed to start an HTTP Server")
|
||||
}
|
||||
|
||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -62,13 +62,13 @@ type datastore struct {
|
|||
sync.Mutex
|
||||
}
|
||||
|
||||
// KVObject is Key/Value interface used by objects to be part of the DataStore
|
||||
// KVObject is Key/Value interface used by objects to be part of the DataStore
|
||||
type KVObject interface {
|
||||
// Key method lets an object to provide the Key to be used in KV Store
|
||||
// Key method lets an object provide the Key to be used in KV Store
|
||||
Key() []string
|
||||
// KeyPrefix method lets an object to return immediate parent key that can be used for tree walk
|
||||
// KeyPrefix method lets an object return immediate parent key that can be used for tree walk
|
||||
KeyPrefix() []string
|
||||
// Value method lets an object to marshal its content to be stored in the KV store
|
||||
// Value method lets an object marshal its content to be stored in the KV store
|
||||
Value() []byte
|
||||
// SetValue is used by the datastore to set the object's value when loaded from the data store.
|
||||
SetValue([]byte) error
|
||||
|
|
|
@ -116,7 +116,7 @@ During registration, the remote driver will receive a POST message to the URL `/
|
|||
|
||||
### RequestPool
|
||||
|
||||
This API is for registering a address pool with the IPAM driver. Multiple identical calls must return the same result.
|
||||
This API is for registering an address pool with the IPAM driver. Multiple identical calls must return the same result.
|
||||
It is the IPAM driver's responsibility to keep a reference count for the pool.
|
||||
|
||||
```go
|
||||
|
|
|
@ -115,7 +115,7 @@ type InterfaceNameInfo interface {
|
|||
// JoinInfo represents a set of resources that the driver has the ability to provide during
|
||||
// join time.
|
||||
type JoinInfo interface {
|
||||
// InterfaceName returns a InterfaceNameInfo go interface to facilitate
|
||||
// InterfaceName returns an InterfaceNameInfo go interface to facilitate
|
||||
// setting the names for the interface.
|
||||
InterfaceName() InterfaceNameInfo
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func createIPVlan(containerIfName, parent, ipvlanMode string) (string, error) {
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("error occoured looking up the %s parent iface %s error: %s", ipvlanType, parent, err)
|
||||
}
|
||||
// Create a ipvlan link
|
||||
// Create an ipvlan link
|
||||
ipvlan := &netlink.IPVlan{
|
||||
LinkAttrs: netlink.LinkAttrs{
|
||||
Name: containerIfName,
|
||||
|
|
|
@ -15,7 +15,7 @@ func TestValidateLink(t *testing.T) {
|
|||
if ok := parentExists(validIface); !ok {
|
||||
t.Fatalf("failed validating loopback %s", validIface)
|
||||
}
|
||||
// test a invalid parent interface validation
|
||||
// test an invalid parent interface validation
|
||||
if ok := parentExists(invalidIface); ok {
|
||||
t.Fatalf("failed to invalidate interface %s", invalidIface)
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ func TestValidateSubLink(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("failed subinterface validation: %v", err)
|
||||
}
|
||||
// test a invalid vid with a valid parent link
|
||||
// test an invalid vid with a valid parent link
|
||||
_, _, err = parseVlan(invalidSubIface1)
|
||||
if err == nil {
|
||||
t.Fatalf("failed subinterface validation test: %s", invalidSubIface1)
|
||||
}
|
||||
// test a valid vid with a valid parent link with a invalid delimiter
|
||||
// test a valid vid with a valid parent link with an invalid delimiter
|
||||
_, _, err = parseVlan(invalidSubIface2)
|
||||
if err == nil {
|
||||
t.Fatalf("failed subinterface validation test: %v", invalidSubIface2)
|
||||
}
|
||||
// test a invalid parent link with a valid vid
|
||||
// test an invalid parent link with a valid vid
|
||||
_, _, err = parseVlan(invalidSubIface3)
|
||||
if err == nil {
|
||||
t.Fatalf("failed subinterface validation test: %v", invalidSubIface3)
|
||||
|
|
|
@ -15,7 +15,7 @@ func TestValidateLink(t *testing.T) {
|
|||
if ok := parentExists(validIface); !ok {
|
||||
t.Fatalf("failed validating loopback %s", validIface)
|
||||
}
|
||||
// test a invalid parent interface validation
|
||||
// test an invalid parent interface validation
|
||||
if ok := parentExists(invalidIface); ok {
|
||||
t.Fatalf("failed to invalidate interface %s", invalidIface)
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ func TestValidateSubLink(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("failed subinterface validation: %v", err)
|
||||
}
|
||||
// test a invalid vid with a valid parent link
|
||||
// test an invalid vid with a valid parent link
|
||||
_, _, err = parseVlan(invalidSubIface1)
|
||||
if err == nil {
|
||||
t.Fatalf("failed subinterface validation test: %s", invalidSubIface1)
|
||||
}
|
||||
// test a valid vid with a valid parent link with a invalid delimiter
|
||||
// test a valid vid with a valid parent link with an invalid delimiter
|
||||
_, _, err = parseVlan(invalidSubIface2)
|
||||
if err == nil {
|
||||
t.Fatalf("failed subinterface validation test: %v", invalidSubIface2)
|
||||
}
|
||||
// test a invalid parent link with a valid vid
|
||||
// test an invalid parent link with a valid vid
|
||||
_, _, err = parseVlan(invalidSubIface3)
|
||||
if err == nil {
|
||||
t.Fatalf("failed subinterface validation test: %v", invalidSubIface3)
|
||||
|
|
|
@ -46,7 +46,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
|||
|
||||
server := httptest.NewServer(mux)
|
||||
if server == nil {
|
||||
t.Fatal("Failed to start a HTTP Server")
|
||||
t.Fatal("Failed to start an HTTP Server")
|
||||
}
|
||||
|
||||
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) {
|
|||
updated = mapset.NewSetFromSlice([]interface{}{addedIP})
|
||||
added, removed = diff(existing, updated)
|
||||
if len(removed) != 2 {
|
||||
t.Fatalf("Diff failed for an remove update. Expecting 2 element, but got %d elements", len(removed))
|
||||
t.Fatalf("Diff failed for a remove update. Expecting 2 element, but got %d elements", len(removed))
|
||||
}
|
||||
if len(added) != 1 {
|
||||
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) {
|
|||
removed := false
|
||||
hd.processCallback(update, func() {}, func(hosts []net.IP) { added = true }, func(hosts []net.IP) { removed = true })
|
||||
if !added {
|
||||
t.Fatalf("Expecting a Added callback notification. But none received")
|
||||
t.Fatalf("Expecting an Added callback notification. But none received")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ const (
|
|||
type Callback interface {
|
||||
// RegisterIpamDriver provides a way for Remote drivers to dynamically register with libnetwork
|
||||
RegisterIpamDriver(name string, driver Ipam) error
|
||||
// RegisterIpamDriverWithCapabilities provides a way for Remote drivers to dynamically register with libnetwork and specify cpaabilities
|
||||
// RegisterIpamDriverWithCapabilities provides a way for Remote drivers to dynamically register with libnetwork and specify capabilities
|
||||
RegisterIpamDriverWithCapabilities(name string, driver Ipam, capability *Capability) error
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
|
|||
|
||||
server := httptest.NewServer(mux)
|
||||
if server == nil {
|
||||
t.Fatal("Failed to start a HTTP Server")
|
||||
t.Fatal("Failed to start an HTTP Server")
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(fmt.Sprintf("/etc/docker/plugins/%s.spec", name), []byte(server.URL), 0644); err != nil {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Package ipamutils provides utililty functions for ipam management
|
||||
// Package ipamutils provides utility functions for ipam management
|
||||
package ipamutils
|
||||
|
||||
import (
|
||||
|
@ -17,7 +17,7 @@ var (
|
|||
initNetworksOnce sync.Once
|
||||
)
|
||||
|
||||
// InitNetworks initializes the pre-defined networks used by the built-in IP allocator
|
||||
// InitNetworks initializes the pre-defined networks used by the built-in IP allocator
|
||||
func InitNetworks() {
|
||||
initNetworksOnce.Do(func() {
|
||||
PredefinedBroadNetworks = initBroadPredefinedNetworks()
|
||||
|
|
|
@ -94,7 +94,7 @@ func (i *Handle) DelService(s *Service) error {
|
|||
return i.doCmd(s, nil, ipvsCmdDelService)
|
||||
}
|
||||
|
||||
// NewDestination creates an new real server in the passed ipvs
|
||||
// NewDestination creates a new real server in the passed ipvs
|
||||
// service which should already be existing in the passed handle.
|
||||
func (i *Handle) NewDestination(s *Service, d *Destination) error {
|
||||
return i.doCmd(s, d, ipvsCmdNewDest)
|
||||
|
|
|
@ -1115,7 +1115,7 @@ func TestEndpointJoin(t *testing.T) {
|
|||
}
|
||||
|
||||
if info.Sandbox() == nil {
|
||||
t.Fatalf("Expected an non-empty sandbox key for a joined endpoint. Instead found a empty sandbox key")
|
||||
t.Fatalf("Expected a non-empty sandbox key for a joined endpoint. Instead found an empty sandbox key")
|
||||
}
|
||||
|
||||
// Check endpoint provided container information
|
||||
|
@ -1314,7 +1314,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
|||
t.Fatalf("SetExternalKey must fail if the corresponding namespace is not created")
|
||||
}
|
||||
} else {
|
||||
// Setting an non-existing key (namespace) must fail
|
||||
// Setting a non-existing key (namespace) must fail
|
||||
if err := sbox.SetKey("this-must-fail"); err == nil {
|
||||
t.Fatalf("Setkey must fail if the corresponding namespace is not created")
|
||||
}
|
||||
|
@ -2018,7 +2018,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
|
|||
mux := http.NewServeMux()
|
||||
server := httptest.NewServer(mux)
|
||||
if server == nil {
|
||||
t.Fatal("Failed to start a HTTP Server")
|
||||
t.Fatal("Failed to start an HTTP Server")
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
|
@ -2069,7 +2069,7 @@ func TestValidRemoteDriver(t *testing.T) {
|
|||
mux := http.NewServeMux()
|
||||
server := httptest.NewServer(mux)
|
||||
if server == nil {
|
||||
t.Fatal("Failed to start a HTTP Server")
|
||||
t.Fatal("Failed to start an HTTP Server")
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ func ReverseIP(IP string) string {
|
|||
return strings.Join(reverseIP, ".")
|
||||
}
|
||||
|
||||
// ParseAlias parses and validates the specified string as a alias format (name:alias)
|
||||
// ParseAlias parses and validates the specified string as an alias format (name:alias)
|
||||
func ParseAlias(val string) (string, string, error) {
|
||||
if val == "" {
|
||||
return "", "", fmt.Errorf("empty string specified for alias")
|
||||
|
|
|
@ -1141,7 +1141,7 @@ func (n *network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPo
|
|||
}
|
||||
|
||||
// If the network belongs to global scope or the pool was
|
||||
// explicitely chosen or it is invalid, do not perform the overlap check.
|
||||
// explicitly chosen or it is invalid, do not perform the overlap check.
|
||||
if n.Scope() == datastore.GlobalScope || preferredPool != "" || !types.IsIPNetValid(pool) {
|
||||
return poolID, pool, meta, nil
|
||||
}
|
||||
|
@ -1165,7 +1165,7 @@ func (n *network) requestPoolHelper(ipam ipamapi.Ipam, addressSpace, preferredPo
|
|||
}()
|
||||
|
||||
// If this is a preferred pool request and the network
|
||||
// is local scope and there is a overlap, we fail the
|
||||
// is local scope and there is an overlap, we fail the
|
||||
// network creation right here. The pool will be
|
||||
// released in the defer.
|
||||
if preferredPool != "" {
|
||||
|
|
|
@ -41,7 +41,7 @@ func (e TypeMismatchError) Error() string {
|
|||
return fmt.Sprintf("type mismatch, field %s require type %v, actual type %v", e.Field, e.ExpectType, e.ActualType)
|
||||
}
|
||||
|
||||
// Generic is an basic type to store arbitrary settings.
|
||||
// Generic is a basic type to store arbitrary settings.
|
||||
type Generic map[string]interface{}
|
||||
|
||||
// NewGeneric returns a new Generic instance.
|
||||
|
|
|
@ -225,7 +225,7 @@ func (n *network) rmLBBackend(ip, vip net.IP, fwMark uint32, rmService bool) {
|
|||
func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, addService bool) {
|
||||
i, err := ipvs.New(sb.Key())
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to create a ipvs handle for sbox %s: %v", sb.Key(), err)
|
||||
logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err)
|
||||
return
|
||||
}
|
||||
defer i.Close()
|
||||
|
@ -267,7 +267,7 @@ func (sb *sandbox) addLBBackend(ip, vip net.IP, fwMark uint32, addService bool)
|
|||
func (sb *sandbox) rmLBBackend(ip, vip net.IP, fwMark uint32, rmService bool) {
|
||||
i, err := ipvs.New(sb.Key())
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to create a ipvs handle for sbox %s: %v", sb.Key(), err)
|
||||
logrus.Errorf("Failed to create an ipvs handle for sbox %s: %v", sb.Key(), err)
|
||||
return
|
||||
}
|
||||
defer i.Close()
|
||||
|
|
|
@ -226,7 +226,7 @@ const (
|
|||
UDP = 17
|
||||
)
|
||||
|
||||
// Protocol represents a IP protocol number
|
||||
// Protocol represents an IP protocol number
|
||||
type Protocol uint8
|
||||
|
||||
func (p Protocol) String() string {
|
||||
|
|
Loading…
Add table
Reference in a new issue