daemon: don't call NetworkMode.IsDefault()
Previous commit made this unnecessary. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
parent
4eed3dcdfe
commit
c4689034fd
3 changed files with 4 additions and 20 deletions
|
@ -658,7 +658,7 @@ func handleMACAddressBC(config *container.Config, hostConfig *container.HostConf
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
if !hostConfig.NetworkMode.IsDefault() && !hostConfig.NetworkMode.IsBridge() && !hostConfig.NetworkMode.IsUserDefined() {
|
if !hostConfig.NetworkMode.IsBridge() && !hostConfig.NetworkMode.IsUserDefined() {
|
||||||
return "", runconfig.ErrConflictContainerNetworkAndMac
|
return "", runconfig.ErrConflictContainerNetworkAndMac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ func handleMACAddressBC(config *container.Config, hostConfig *container.HostConf
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
var warning string
|
var warning string
|
||||||
if hostConfig.NetworkMode.IsDefault() || hostConfig.NetworkMode.IsBridge() || hostConfig.NetworkMode.IsUserDefined() {
|
if hostConfig.NetworkMode.IsBridge() || hostConfig.NetworkMode.IsUserDefined() {
|
||||||
nwName := hostConfig.NetworkMode.NetworkName()
|
nwName := hostConfig.NetworkMode.NetworkName()
|
||||||
// If there's no endpoint config, create a place to store the configured address.
|
// If there's no endpoint config, create a place to store the configured address.
|
||||||
if len(networkingConfig.EndpointsConfig) == 0 {
|
if len(networkingConfig.EndpointsConfig) == 0 {
|
||||||
|
|
|
@ -420,9 +420,6 @@ func (daemon *Daemon) updateContainerNetworkSettings(container *container.Contai
|
||||||
}
|
}
|
||||||
|
|
||||||
networkName := mode.NetworkName()
|
networkName := mode.NetworkName()
|
||||||
if mode.IsDefault() {
|
|
||||||
networkName = daemon.netController.Config().DefaultNetwork
|
|
||||||
}
|
|
||||||
|
|
||||||
if mode.IsUserDefined() {
|
if mode.IsUserDefined() {
|
||||||
var err error
|
var err error
|
||||||
|
@ -461,15 +458,6 @@ func (daemon *Daemon) updateContainerNetworkSettings(container *container.Contai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert any settings added by client in default name to
|
|
||||||
// engine's default network name key
|
|
||||||
if mode.IsDefault() {
|
|
||||||
if nConf, ok := container.NetworkSettings.Networks[mode.NetworkName()]; ok {
|
|
||||||
container.NetworkSettings.Networks[networkName] = nConf
|
|
||||||
delete(container.NetworkSettings.Networks, mode.NetworkName())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !mode.IsUserDefined() {
|
if !mode.IsUserDefined() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,12 +130,8 @@ func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *contai
|
||||||
// unconditionally, to keep backward compatibility with clients that use
|
// unconditionally, to keep backward compatibility with clients that use
|
||||||
// unversioned API endpoints.
|
// unversioned API endpoints.
|
||||||
if container.Config != nil && container.Config.MacAddress == "" { //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
if container.Config != nil && container.Config.MacAddress == "" { //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||||
if nwm := hostConfig.NetworkMode; nwm.IsDefault() || nwm.IsBridge() || nwm.IsUserDefined() {
|
if nwm := hostConfig.NetworkMode; nwm.IsBridge() || nwm.IsUserDefined() {
|
||||||
name := nwm.NetworkName()
|
if epConf, ok := container.NetworkSettings.Networks[nwm.NetworkName()]; ok {
|
||||||
if nwm.IsDefault() {
|
|
||||||
name = daemon.netController.Config().DefaultNetwork
|
|
||||||
}
|
|
||||||
if epConf, ok := container.NetworkSettings.Networks[name]; ok {
|
|
||||||
container.Config.MacAddress = epConf.DesiredMacAddress //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
container.Config.MacAddress = epConf.DesiredMacAddress //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue