mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
libnetwork: macvlan: reduce use of const for driver name
Inlining the string makes the code more grep'able; renaming the const to "driverName" to reflect the remaining uses of it. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
aca80d1cda
commit
b1a6d5388d
4 changed files with 10 additions and 9 deletions
|
@ -17,7 +17,7 @@ const (
|
||||||
vethLen = 7
|
vethLen = 7
|
||||||
containerVethPrefix = "eth"
|
containerVethPrefix = "eth"
|
||||||
vethPrefix = "veth"
|
vethPrefix = "veth"
|
||||||
macvlanType = "macvlan" // driver type name
|
driverName = "macvlan" // driver type name
|
||||||
modePrivate = "private" // macvlan mode private
|
modePrivate = "private" // macvlan mode private
|
||||||
modeVepa = "vepa" // macvlan mode vepa
|
modeVepa = "vepa" // macvlan mode vepa
|
||||||
modeBridge = "bridge" // macvlan mode bridge
|
modeBridge = "bridge" // macvlan mode bridge
|
||||||
|
@ -69,7 +69,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return dc.RegisterDriver(macvlanType, d, c)
|
return dc.RegisterDriver(driverName, d, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||||
|
@ -85,7 +85,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) Type() string {
|
func (d *driver) Type() string {
|
||||||
return macvlanType
|
return driverName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) IsBuiltIn() bool {
|
func (d *driver) IsBuiltIn() bool {
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
|
||||||
if opt, ok := epOptions[netlabel.PortMap]; ok {
|
if opt, ok := epOptions[netlabel.PortMap]; ok {
|
||||||
if _, ok := opt.([]types.PortBinding); ok {
|
if _, ok := opt.([]types.PortBinding); ok {
|
||||||
if len(opt.([]types.PortBinding)) > 0 {
|
if len(opt.([]types.PortBinding)) > 0 {
|
||||||
logrus.Warnf("%s driver does not support port mappings", macvlanType)
|
logrus.Warnf("macvlan driver does not support port mappings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
|
||||||
if opt, ok := epOptions[netlabel.ExposedPorts]; ok {
|
if opt, ok := epOptions[netlabel.ExposedPorts]; ok {
|
||||||
if _, ok := opt.([]types.TransportPort); ok {
|
if _, ok := opt.([]types.TransportPort); ok {
|
||||||
if len(opt.([]types.TransportPort)) > 0 {
|
if len(opt.([]types.TransportPort)) > 0 {
|
||||||
logrus.Warnf("%s driver does not support port exposures", macvlanType)
|
logrus.Warnf("macvlan driver does not support port exposures")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,9 @@ func (d *driver) createNetwork(config *configuration) (bool, error) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
config.CreatedSlaveLink = true
|
config.CreatedSlaveLink = true
|
||||||
|
|
||||||
// notify the user in logs that they have limited communications
|
// notify the user in logs that they have limited communications
|
||||||
logrus.Debugf("Empty -o parent= limit communications to other containers inside of network: %s",
|
logrus.Debugf("Empty -o parent= flags limit communications to other containers inside of network: %s",
|
||||||
config.Parent)
|
config.Parent)
|
||||||
} else {
|
} else {
|
||||||
// if the subinterface parent_iface.vlan_id checks do not pass, return err.
|
// if the subinterface parent_iface.vlan_id checks do not pass, return err.
|
||||||
|
|
|
@ -31,7 +31,7 @@ func createMacVlan(containerIfName, parent, macvlanMode string) (string, error)
|
||||||
// Get the link for the master index (Example: the docker host eth iface)
|
// Get the link for the master index (Example: the docker host eth iface)
|
||||||
parentLink, err := ns.NlHandle().LinkByName(parent)
|
parentLink, err := ns.NlHandle().LinkByName(parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error occurred looking up the %s parent iface %s error: %s", macvlanType, parent, err)
|
return "", fmt.Errorf("error occurred looking up the macvlan parent iface %s error: %s", parent, err)
|
||||||
}
|
}
|
||||||
// Create a macvlan link
|
// Create a macvlan link
|
||||||
macvlan := &netlink.Macvlan{
|
macvlan := &netlink.Macvlan{
|
||||||
|
@ -43,7 +43,7 @@ func createMacVlan(containerIfName, parent, macvlanMode string) (string, error)
|
||||||
}
|
}
|
||||||
if err := ns.NlHandle().LinkAdd(macvlan); err != nil {
|
if err := ns.NlHandle().LinkAdd(macvlan); err != nil {
|
||||||
// If a user creates a macvlan and ipvlan on same parent, only one slave iface can be active at a time.
|
// If a user creates a macvlan and ipvlan on same parent, only one slave iface can be active at a time.
|
||||||
return "", fmt.Errorf("failed to create the %s port: %v", macvlanType, err)
|
return "", fmt.Errorf("failed to create the macvlan port: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return macvlan.Attrs().Name, nil
|
return macvlan.Attrs().Name, nil
|
||||||
|
@ -170,7 +170,7 @@ func createDummyLink(dummyName, truncNetID string) error {
|
||||||
}
|
}
|
||||||
parentDummyLink, err := ns.NlHandle().LinkByName(dummyName)
|
parentDummyLink, err := ns.NlHandle().LinkByName(dummyName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error occurred looking up the %s parent iface %s error: %s", macvlanType, dummyName, err)
|
return fmt.Errorf("error occurred looking up the macvlan parent iface %s error: %s", dummyName, err)
|
||||||
}
|
}
|
||||||
// bring the new netlink iface up
|
// bring the new netlink iface up
|
||||||
if err := ns.NlHandle().LinkSetUp(parentDummyLink); err != nil {
|
if err := ns.NlHandle().LinkSetUp(parentDummyLink); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue