func (i *InterfaceInfo) Validate() error {
	if i.MACAddress != "" {
		if _, err := net.ParseMAC(i.MACAddress); err != nil {
			return errors.NotValidf("link-layer device hardware address %q", i.MACAddress)
		}
	}

	if i.InterfaceName == "" {
		return errors.NotValidf("link-layer device %q, empty name", i.MACAddress)
	}

	if !IsValidLinkLayerDeviceName(i.InterfaceName) {
		// TODO (manadart 2020-07-07): This preserves prior behaviour.
		// If we are waving invalid names through, I'm not sure of the value.
		logger.Warningf("link-layer device %q has an invalid name, %q", i.MACAddress, i.InterfaceName)
	}

	if !IsValidLinkLayerDeviceType(string(i.InterfaceType)) {
		return errors.NotValidf("link-layer device %q, type %q", i.InterfaceName, i.InterfaceType)
	}

	return nil
}
// Validate checks that the receiver looks like a real interface.
// An error is returned if invalid members are detected.
Validate checks that the receiver looks like a real interface.
An error is returned if invalid members are detected.
// Validate checks that the receiver looks like a real interface . // An error is returned if invalid members are detected .
func (i *InterfaceInfo) Validate() error {
	if i.MACAddress != "" {
		if _, err := net.ParseMAC(i.MACAddress); err != nil {
			return errors.NotValidf("link-layer device hardware address %q", i.MACAddress)
		}
	}
	if i.InterfaceName == "" {
		return errors.NotValidf("link-layer device %q, empty name", i.MACAddress)
	}
	if !IsValidLinkLayerDeviceName(i.InterfaceName) {
		logger.Warningf("link-layer device %q has an invalid name, %q", i.MACAddress, i.InterfaceName)
	}
	if !IsValidLinkLayerDeviceType(string(i.InterfaceType)) {
		return errors.NotValidf("link-layer device %q, type %q", i.InterfaceName, i.InterfaceType)
	}
	return nil
}
func ( i * InterfaceInfo ) Validate ( ) error { if i . MACAddress != " " { if _ , err := net . ParseMAC ( i . MACAddress ) ; err != nil { return errors . NotValidf ( " " , i . MACAddress ) } } if i . InterfaceName == " " { return errors . NotValidf ( " " , i . MACAddress ) } if ! IsValidLinkLayerDeviceName ( i . InterfaceName ) { logger . Warningf ( " " , i . MACAddress , i . InterfaceName ) } if ! IsValidLinkLayerDeviceType ( string ( i . InterfaceType ) ) { return errors . NotValidf ( " " , i . InterfaceName , i . InterfaceType ) } return nil }
Validate checks that the receiver looks like a real interface.
Validate checks that the receiver looks like a real interface .
// TODO (manadart 2020-07-07): This preserves prior behaviour. // If we are waving invalid names through, I'm not sure of the value.