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:
Sebastiaan van Stijn 2022-07-01 11:32:46 +02:00
parent aca80d1cda
commit b1a6d5388d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 10 additions and 9 deletions

View File

@ -17,7 +17,7 @@ const (
vethLen = 7
containerVethPrefix = "eth"
vethPrefix = "veth"
macvlanType = "macvlan" // driver type name
driverName = "macvlan" // driver type name
modePrivate = "private" // macvlan mode private
modeVepa = "vepa" // macvlan mode vepa
modeBridge = "bridge" // macvlan mode bridge
@ -69,7 +69,7 @@ func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
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) {
@ -85,7 +85,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
}
func (d *driver) Type() string {
return macvlanType
return driverName
}
func (d *driver) IsBuiltIn() bool {

View File

@ -47,7 +47,7 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
if opt, ok := epOptions[netlabel.PortMap]; ok {
if _, ok := opt.([]types.PortBinding); ok {
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 _, ok := opt.([]types.TransportPort); ok {
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")
}
}
}

View File

@ -78,8 +78,9 @@ func (d *driver) createNetwork(config *configuration) (bool, error) {
return false, err
}
config.CreatedSlaveLink = true
// 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)
} else {
// if the subinterface parent_iface.vlan_id checks do not pass, return err.

View File

@ -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)
parentLink, err := ns.NlHandle().LinkByName(parent)
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
macvlan := &netlink.Macvlan{
@ -43,7 +43,7 @@ func createMacVlan(containerIfName, parent, macvlanMode string) (string, error)
}
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.
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
@ -170,7 +170,7 @@ func createDummyLink(dummyName, truncNetID string) error {
}
parentDummyLink, err := ns.NlHandle().LinkByName(dummyName)
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
if err := ns.NlHandle().LinkSetUp(parentDummyLink); err != nil {