Repository: moby/moby
File: libnetwork/driverapi/driverapi.go (Go)

Code before:
	// only invoked for the global scope driver.
	EventNotify(event EventType, nid string, tableName string, key string, value []byte)

	// DecodeTableEntry passes the driver a key, value pair from table it registered
	// with libnetwork. Driver should return {object ID, map[string]string} tuple.
	// If DecodeTableEntry is called for a table associated with NetworkObject or
	// EndpointObject the return object ID should be the network id or endpoint id
	// associated with that entry. map should have information about the object that
	// can be presented to the user.
	// For example: overlay driver returns the VTEP IP of the host that has the endpoint
	// which is shown in 'network inspect --verbose'
	DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string)

	// Type returns the type of this driver, the network type this driver manages
	Type() string

	// IsBuiltIn returns true if it is a built-in driver
	IsBuiltIn() bool
}

// ExtConner is an optional interface for a network driver.
type ExtConner interface {
	// ProgramExternalConnectivity tells the driver the ids of the endpoints
	// currently acting as the container's default gateway for IPv4 and IPv6 are
	// passed as gw4Id/gw6Id. (Those endpoints may be managed by different network
	// drivers. If there is no gateway, the id will be the empty string.)
	//
	// This method is called after Driver.Join, before Driver.Leave, and when eid
	// is or was equal to gw4Id or gw6Id, and there's a change. It may also be
	// called when the gateways have not changed.
	//
	// When an endpoint acting as a gateway is deleted, this function is called
	// with that endpoint's id, and empty gateway ids (even if another endpoint
	// is present and will shortly be selected as the gateway).
	ProgramExternalConnectivity(ctx context.Context, nid, eid string, gw4Id, gw6Id string) error
}

// GwAllocChecker is an optional interface for a network driver.
type GwAllocChecker interface {
	// GetSkipGwAlloc returns true if the opts describe a network
	// that does not need a gateway IPv4/IPv6 address, else false.
	GetSkipGwAlloc(opts options.Generic) (skipIPv4, skipIPv6 bool, err error)
}

// NetworkInfo provides a go interface for drivers to provide network
// specific information to libnetwork.
type NetworkInfo interface {
	// TableEventRegister registers driver interest in a given
	// table name.
	TableEventRegister(tableName string, objType ObjectType) error


Review comment (suggestion):
Nit: grammar
```suggestion
	// ProgramExternalConnectivity tells the driver the ids of the endpoints
	// currently acting as the container's default gateway for IPv4 and IPv6,
	// passed as gw4Id and gw6Id, respectively. (Those endpoints may be managed by
	// different network drivers. If there is no gateway, the id will be the empty
	// string.)
```

Code after:
	// only invoked for the global scope driver.
	EventNotify(event EventType, nid string, tableName string, key string, value []byte)

	// DecodeTableEntry passes the driver a key, value pair from table it registered
	// with libnetwork. Driver should return {object ID, map[string]string} tuple.
	// If DecodeTableEntry is called for a table associated with NetworkObject or
	// EndpointObject the return object ID should be the network id or endpoint id
	// associated with that entry. map should have information about the object that
	// can be presented to the user.
	// For example: overlay driver returns the VTEP IP of the host that has the endpoint
	// which is shown in 'network inspect --verbose'
	DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string)

	// Type returns the type of this driver, the network type this driver manages
	Type() string

	// IsBuiltIn returns true if it is a built-in driver
	IsBuiltIn() bool
}

// ExtConner is an optional interface for a network driver.
type ExtConner interface {
	// ProgramExternalConnectivity tells the driver the ids of the endpoints
	// currently acting as the container's default gateway for IPv4 and IPv6,
	// passed as gw4Id/gw6Id. (Those endpoints may be managed by different network
	// drivers. If there is no gateway, the id will be the empty string.)
	//
	// This method is called after Driver.Join, before Driver.Leave, and when eid
	// is or was equal to gw4Id or gw6Id, and there's a change. It may also be
	// called when the gateways have not changed.
	//
	// When an endpoint acting as a gateway is deleted, this function is called
	// with that endpoint's id in eid, and empty gateway ids (even if another
	// is present and will shortly be selected as the gateway).
	ProgramExternalConnectivity(ctx context.Context, nid, eid string, gw4Id, gw6Id string) error
}

// GwAllocChecker is an optional interface for a network driver.
type GwAllocChecker interface {
	// GetSkipGwAlloc returns true if the opts describe a network
	// that does not need a gateway IPv4/IPv6 address, else false.
	GetSkipGwAlloc(opts options.Generic) (skipIPv4, skipIPv6 bool, err error)
}

// NetworkInfo provides a go interface for drivers to provide network
// specific information to libnetwork.
type NetworkInfo interface {
	// TableEventRegister registers driver interest in a given
	// table name.
	TableEventRegister(tableName string, objType ObjectType) error