Replace two array with a map type, make it easier to understand.
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn> update Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn> update Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
This commit is contained in:
parent
c5f4a1ab19
commit
1989b1b58c
1 changed files with 5 additions and 8 deletions
|
@ -501,23 +501,20 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) error {
|
|||
}
|
||||
|
||||
}
|
||||
var (
|
||||
networks []string
|
||||
epConfigs []*network.EndpointSettings
|
||||
)
|
||||
|
||||
// the intermediate map is necessary because "connectToNetwork" modifies "container.NetworkSettings.Networks"
|
||||
networks := make(map[string]*network.EndpointSettings)
|
||||
for n, epConf := range container.NetworkSettings.Networks {
|
||||
if n == defaultNetName {
|
||||
continue
|
||||
}
|
||||
|
||||
networks = append(networks, n)
|
||||
epConfigs = append(epConfigs, epConf)
|
||||
networks[n] = epConf
|
||||
}
|
||||
|
||||
for i, epConf := range epConfigs {
|
||||
for netName, epConf := range networks {
|
||||
cleanOperationalData(epConf)
|
||||
if err := daemon.connectToNetwork(container, networks[i], epConf.EndpointSettings, updateSettings); err != nil {
|
||||
if err := daemon.connectToNetwork(container, netName, epConf.EndpointSettings, updateSettings); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue