fix(container-creation): prevent duplicate MAC addresses after edit (#1645) (#2993)

pull/3213/head
Frans-Jan van Steenbeek 2019-10-03 04:37:34 +02:00 committed by Anthony Lapenna
parent 81e9484dd3
commit 6c996377f5
1 changed files with 2 additions and 5 deletions

View File

@ -402,16 +402,13 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai
}
}
$scope.config.NetworkingConfig.EndpointsConfig[$scope.config.HostConfig.NetworkMode] = d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode];
// Mac Address
if(Object.keys(d.NetworkSettings.Networks).length) {
if(Object.keys(d.NetworkSettings.Networks).length > 1) {
var firstNetwork = d.NetworkSettings.Networks[Object.keys(d.NetworkSettings.Networks)[0]];
$scope.formValues.MacAddress = firstNetwork.MacAddress;
$scope.config.NetworkingConfig.EndpointsConfig[$scope.config.HostConfig.NetworkMode] = firstNetwork;
$scope.extraNetworks = angular.copy(d.NetworkSettings.Networks);
delete $scope.extraNetworks[Object.keys(d.NetworkSettings.Networks)[0]];
} else {
$scope.formValues.MacAddress = '';
}
$scope.formValues.MacAddress = d.Config.MacAddress;
// ExtraHosts
if ($scope.config.HostConfig.ExtraHosts) {