2019-03-21 05:46:49 +00:00
|
|
|
import moment from 'moment';
|
2020-08-09 22:27:27 +00:00
|
|
|
import _ from 'lodash-es';
|
2019-11-27 22:36:39 +00:00
|
|
|
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
2022-01-04 12:16:09 +00:00
|
|
|
import { confirmContainerDeletion } from '@/portainer/services/modal.service/prompt';
|
2022-02-14 13:51:43 +00:00
|
|
|
import { FeatureId } from 'Portainer/feature-flags/enums';
|
2022-03-16 06:35:32 +00:00
|
|
|
import { ResourceControlType } from '@/portainer/access-control/types';
|
2019-03-21 05:46:49 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.docker').controller('ContainerController', [
|
|
|
|
'$q',
|
|
|
|
'$scope',
|
|
|
|
'$state',
|
|
|
|
'$transition$',
|
|
|
|
'$filter',
|
|
|
|
'$async',
|
|
|
|
'Commit',
|
|
|
|
'ContainerHelper',
|
|
|
|
'ContainerService',
|
|
|
|
'ImageHelper',
|
|
|
|
'NetworkService',
|
|
|
|
'Notifications',
|
|
|
|
'ModalService',
|
|
|
|
'ResourceControlService',
|
|
|
|
'RegistryService',
|
|
|
|
'ImageService',
|
|
|
|
'HttpRequestHelper',
|
|
|
|
'Authentication',
|
2021-02-09 08:09:06 +00:00
|
|
|
'endpoint',
|
2020-04-10 21:54:53 +00:00
|
|
|
function (
|
|
|
|
$q,
|
|
|
|
$scope,
|
|
|
|
$state,
|
|
|
|
$transition$,
|
|
|
|
$filter,
|
|
|
|
$async,
|
|
|
|
Commit,
|
|
|
|
ContainerHelper,
|
|
|
|
ContainerService,
|
|
|
|
ImageHelper,
|
|
|
|
NetworkService,
|
|
|
|
Notifications,
|
|
|
|
ModalService,
|
|
|
|
ResourceControlService,
|
|
|
|
RegistryService,
|
|
|
|
ImageService,
|
|
|
|
HttpRequestHelper,
|
2020-07-29 02:52:23 +00:00
|
|
|
Authentication,
|
2021-02-09 08:09:06 +00:00
|
|
|
endpoint
|
2020-04-10 21:54:53 +00:00
|
|
|
) {
|
2022-03-16 06:35:32 +00:00
|
|
|
$scope.resourceType = ResourceControlType.Container;
|
2021-07-14 09:15:21 +00:00
|
|
|
$scope.endpoint = endpoint;
|
2021-08-12 11:28:25 +00:00
|
|
|
$scope.isAdmin = Authentication.isAdmin();
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.activityTime = 0;
|
|
|
|
$scope.portBindings = [];
|
|
|
|
$scope.displayRecreateButton = false;
|
2022-07-20 00:39:44 +00:00
|
|
|
$scope.displayCreateWebhookButton = false;
|
2022-02-14 13:51:43 +00:00
|
|
|
$scope.containerWebhookFeature = FeatureId.CONTAINER_WEBHOOK;
|
2020-04-10 21:54:53 +00:00
|
|
|
|
|
|
|
$scope.config = {
|
|
|
|
RegistryModel: new PorImageRegistryModel(),
|
|
|
|
commitInProgress: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.state = {
|
|
|
|
recreateContainerInProgress: false,
|
|
|
|
joinNetworkInProgress: false,
|
|
|
|
leaveNetworkInProgress: false,
|
2021-08-12 11:28:25 +00:00
|
|
|
pullImageValidity: false,
|
2020-04-10 21:54:53 +00:00
|
|
|
};
|
|
|
|
|
2021-08-12 11:28:25 +00:00
|
|
|
$scope.setPullImageValidity = setPullImageValidity;
|
|
|
|
function setPullImageValidity(validity) {
|
|
|
|
$scope.state.pullImageValidity = validity;
|
|
|
|
}
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.updateRestartPolicy = updateRestartPolicy;
|
|
|
|
|
2022-03-16 06:35:32 +00:00
|
|
|
$scope.onUpdateResourceControlSuccess = function () {
|
|
|
|
$state.reload();
|
|
|
|
};
|
|
|
|
|
2022-07-17 23:02:14 +00:00
|
|
|
$scope.computeDockerGPUCommand = () => {
|
|
|
|
const gpuOptions = _.find($scope.container.HostConfig.DeviceRequests, function (o) {
|
|
|
|
return o.Driver === 'nvidia' || o.Capabilities[0][0] === 'gpu';
|
|
|
|
});
|
|
|
|
if (!gpuOptions) {
|
|
|
|
return 'No GPU config found';
|
|
|
|
}
|
|
|
|
let gpuStr = 'all';
|
|
|
|
if (gpuOptions.Count !== -1) {
|
|
|
|
gpuStr = `"device=${_.join(gpuOptions.DeviceIDs, ',')}"`;
|
|
|
|
}
|
|
|
|
// we only support a single set of capabilities for now
|
|
|
|
// creation UI needs to be reworked in order to support OR combinations of AND capabilities
|
|
|
|
const capStr = `"capabilities=${_.join(gpuOptions.Capabilities[0], ',')}"`;
|
|
|
|
return `${gpuStr},${capStr}`;
|
|
|
|
};
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
var update = function () {
|
|
|
|
var nodeName = $transition$.params().nodeName;
|
|
|
|
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
|
|
|
|
$scope.nodeName = nodeName;
|
|
|
|
|
|
|
|
ContainerService.container($transition$.params().id)
|
|
|
|
.then(function success(data) {
|
|
|
|
var container = data;
|
|
|
|
$scope.container = container;
|
|
|
|
$scope.container.edit = false;
|
|
|
|
$scope.container.newContainerName = $filter('trimcontainername')(container.Name);
|
|
|
|
|
|
|
|
if (container.State.Running) {
|
|
|
|
$scope.activityTime = moment.duration(moment(container.State.StartedAt).utc().diff(moment().utc())).humanize();
|
|
|
|
} else if (container.State.Status === 'created') {
|
|
|
|
$scope.activityTime = moment.duration(moment(container.Created).utc().diff(moment().utc())).humanize();
|
|
|
|
} else {
|
|
|
|
$scope.activityTime = moment.duration(moment().utc().diff(moment(container.State.FinishedAt).utc())).humanize();
|
|
|
|
}
|
2016-06-02 05:34:03 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.portBindings = [];
|
|
|
|
if (container.NetworkSettings.Ports) {
|
2020-08-09 22:27:27 +00:00
|
|
|
_.forEach(Object.keys(container.NetworkSettings.Ports), function (key) {
|
|
|
|
if (container.NetworkSettings.Ports[key]) {
|
|
|
|
_.forEach(container.NetworkSettings.Ports[key], (portMapping) => {
|
|
|
|
const mapping = {};
|
|
|
|
mapping.container = key;
|
|
|
|
mapping.host = `${portMapping.HostIp}:${portMapping.HostPort}`;
|
|
|
|
$scope.portBindings.push(mapping);
|
|
|
|
});
|
2020-04-10 21:54:53 +00:00
|
|
|
}
|
|
|
|
});
|
2016-08-19 06:41:45 +00:00
|
|
|
}
|
2019-12-03 21:47:07 +00:00
|
|
|
|
2021-02-18 13:46:26 +00:00
|
|
|
$scope.container.Config.Env = _.sortBy($scope.container.Config.Env, _.toLower);
|
2020-04-10 21:54:53 +00:00
|
|
|
const inSwarm = $scope.container.Config.Labels['com.docker.swarm.service.id'];
|
|
|
|
const autoRemove = $scope.container.HostConfig.AutoRemove;
|
|
|
|
const admin = Authentication.isAdmin();
|
2020-07-29 02:52:23 +00:00
|
|
|
const {
|
|
|
|
allowContainerCapabilitiesForRegularUsers,
|
|
|
|
allowHostNamespaceForRegularUsers,
|
|
|
|
allowDeviceMappingForRegularUsers,
|
2021-04-12 07:40:45 +00:00
|
|
|
allowSysctlSettingForRegularUsers,
|
2020-07-29 02:52:23 +00:00
|
|
|
allowBindMountsForRegularUsers,
|
|
|
|
allowPrivilegedModeForRegularUsers,
|
2021-02-09 08:09:06 +00:00
|
|
|
} = endpoint.SecuritySettings;
|
2020-07-29 02:52:23 +00:00
|
|
|
|
|
|
|
const settingRestrictsRegularUsers =
|
|
|
|
!allowContainerCapabilitiesForRegularUsers ||
|
|
|
|
!allowBindMountsForRegularUsers ||
|
|
|
|
!allowDeviceMappingForRegularUsers ||
|
2021-04-12 07:40:45 +00:00
|
|
|
!allowSysctlSettingForRegularUsers ||
|
2020-07-29 02:52:23 +00:00
|
|
|
!allowHostNamespaceForRegularUsers ||
|
|
|
|
!allowPrivilegedModeForRegularUsers;
|
2019-12-03 21:47:07 +00:00
|
|
|
|
2020-08-11 05:41:37 +00:00
|
|
|
$scope.displayRecreateButton = !inSwarm && !autoRemove && (admin || !settingRestrictsRegularUsers);
|
2022-07-20 00:39:44 +00:00
|
|
|
$scope.displayCreateWebhookButton = $scope.displayRecreateButton;
|
2020-04-10 21:54:53 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve container info');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function executeContainerAction(id, action, successMessage, errorMessage) {
|
|
|
|
action(id)
|
|
|
|
.then(function success() {
|
|
|
|
Notifications.success(successMessage, id);
|
|
|
|
update();
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, errorMessage);
|
|
|
|
});
|
2019-11-27 22:36:39 +00:00
|
|
|
}
|
2016-06-02 05:34:03 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.start = function () {
|
|
|
|
var successMessage = 'Container successfully started';
|
|
|
|
var errorMessage = 'Unable to start container';
|
|
|
|
executeContainerAction($transition$.params().id, ContainerService.startContainer, successMessage, errorMessage);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.stop = function () {
|
|
|
|
var successMessage = 'Container successfully stopped';
|
|
|
|
var errorMessage = 'Unable to stop container';
|
|
|
|
executeContainerAction($transition$.params().id, ContainerService.stopContainer, successMessage, errorMessage);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.kill = function () {
|
|
|
|
var successMessage = 'Container successfully killed';
|
|
|
|
var errorMessage = 'Unable to kill container';
|
|
|
|
executeContainerAction($transition$.params().id, ContainerService.killContainer, successMessage, errorMessage);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.pause = function () {
|
|
|
|
var successMessage = 'Container successfully paused';
|
|
|
|
var errorMessage = 'Unable to pause container';
|
|
|
|
executeContainerAction($transition$.params().id, ContainerService.pauseContainer, successMessage, errorMessage);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.unpause = function () {
|
|
|
|
var successMessage = 'Container successfully resumed';
|
|
|
|
var errorMessage = 'Unable to resume container';
|
|
|
|
executeContainerAction($transition$.params().id, ContainerService.resumeContainer, successMessage, errorMessage);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.restart = function () {
|
|
|
|
var successMessage = 'Container successfully restarted';
|
|
|
|
var errorMessage = 'Unable to restart container';
|
|
|
|
executeContainerAction($transition$.params().id, ContainerService.restartContainer, successMessage, errorMessage);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.renameContainer = function () {
|
|
|
|
var container = $scope.container;
|
|
|
|
ContainerService.renameContainer($transition$.params().id, container.newContainerName)
|
|
|
|
.then(function success() {
|
|
|
|
container.Name = container.newContainerName;
|
|
|
|
Notifications.success('Container successfully renamed', container.Name);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
container.newContainerName = container.Name;
|
|
|
|
Notifications.error('Failure', err, 'Unable to rename container');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$scope.container.edit = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.containerLeaveNetwork = function containerLeaveNetwork(container, networkId) {
|
|
|
|
$scope.state.leaveNetworkInProgress = true;
|
|
|
|
NetworkService.disconnectContainer(networkId, container.Id, false)
|
|
|
|
.then(function success() {
|
|
|
|
Notifications.success('Container left network', container.Id);
|
|
|
|
$state.reload();
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to disconnect container from network');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$scope.state.leaveNetworkInProgress = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.containerJoinNetwork = function containerJoinNetwork(container, networkId) {
|
|
|
|
$scope.state.joinNetworkInProgress = true;
|
|
|
|
NetworkService.connectContainer(networkId, container.Id)
|
|
|
|
.then(function success() {
|
|
|
|
Notifications.success('Container joined network', container.Id);
|
|
|
|
$state.reload();
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to connect container to network');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$scope.state.joinNetworkInProgress = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
async function commitContainerAsync() {
|
|
|
|
$scope.config.commitInProgress = true;
|
|
|
|
const registryModel = $scope.config.RegistryModel;
|
|
|
|
const imageConfig = ImageHelper.createImageConfigForContainer(registryModel);
|
|
|
|
try {
|
|
|
|
await Commit.commitContainer({ id: $transition$.params().id, repo: imageConfig.fromImage }).$promise;
|
|
|
|
Notifications.success('Image created', $transition$.params().id);
|
|
|
|
$state.reload();
|
|
|
|
} catch (err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to create image');
|
|
|
|
$scope.config.commitInProgress = false;
|
|
|
|
}
|
2017-04-25 08:20:57 +00:00
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
|
|
|
|
$scope.commit = function () {
|
|
|
|
return $async(commitContainerAsync);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.confirmRemove = function () {
|
|
|
|
var title = 'You are about to remove a container.';
|
|
|
|
if ($scope.container.State.Running) {
|
|
|
|
title = 'You are about to remove a running container.';
|
|
|
|
}
|
2022-01-04 12:16:09 +00:00
|
|
|
|
|
|
|
confirmContainerDeletion(title, function (result) {
|
2020-04-10 21:54:53 +00:00
|
|
|
if (!result) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-01 10:18:06 +00:00
|
|
|
var cleanAssociatedVolumes = false;
|
|
|
|
if (result[0]) {
|
|
|
|
cleanAssociatedVolumes = true;
|
|
|
|
}
|
2018-05-06 07:15:57 +00:00
|
|
|
removeContainer(cleanAssociatedVolumes);
|
2020-04-10 21:54:53 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function removeContainer(cleanAssociatedVolumes) {
|
|
|
|
ContainerService.remove($scope.container, cleanAssociatedVolumes)
|
|
|
|
.then(function success() {
|
2022-08-10 05:07:35 +00:00
|
|
|
Notifications.success('Success', 'Container successfully removed');
|
2020-04-10 21:54:53 +00:00
|
|
|
$state.go('docker.containers', {}, { reload: true });
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to remove container');
|
|
|
|
});
|
2018-08-13 19:13:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function recreateContainer(pullImage) {
|
|
|
|
var container = $scope.container;
|
|
|
|
var config = ContainerHelper.configFromContainer(container.Model);
|
|
|
|
$scope.state.recreateContainerInProgress = true;
|
|
|
|
var isRunning = container.State.Running;
|
|
|
|
|
|
|
|
return pullImageIfNeeded()
|
|
|
|
.then(stopContainerIfNeeded)
|
|
|
|
.then(renameContainer)
|
|
|
|
.then(setMainNetworkAndCreateContainer)
|
|
|
|
.then(connectContainerToOtherNetworks)
|
|
|
|
.then(startContainerIfNeeded)
|
|
|
|
.then(createResourceControl)
|
|
|
|
.then(deleteOldContainer)
|
|
|
|
.then(notifyAndChangeView)
|
|
|
|
.catch(notifyOnError);
|
|
|
|
|
|
|
|
function stopContainerIfNeeded() {
|
|
|
|
if (!isRunning) {
|
|
|
|
return $q.when();
|
|
|
|
}
|
|
|
|
return ContainerService.stopContainer(container.Id);
|
|
|
|
}
|
2018-08-13 19:13:43 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function renameContainer() {
|
|
|
|
return ContainerService.renameContainer(container.Id, container.Name + '-old');
|
2018-08-13 19:13:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function pullImageIfNeeded() {
|
|
|
|
if (!pullImage) {
|
|
|
|
return $q.when();
|
|
|
|
}
|
2021-07-14 09:15:21 +00:00
|
|
|
return RegistryService.retrievePorRegistryModelFromRepository(container.Config.Image, endpoint.Id).then((registryModel) => {
|
2021-12-08 04:07:45 +00:00
|
|
|
return ImageService.pullImage(registryModel, false);
|
2020-04-10 21:54:53 +00:00
|
|
|
});
|
2018-08-13 19:13:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function setMainNetworkAndCreateContainer() {
|
|
|
|
var networks = config.NetworkingConfig.EndpointsConfig;
|
|
|
|
var networksNames = Object.keys(networks);
|
|
|
|
if (networksNames.length > 1) {
|
|
|
|
config.NetworkingConfig.EndpointsConfig = {};
|
|
|
|
config.NetworkingConfig.EndpointsConfig[networksNames[0]] = networks[0];
|
|
|
|
}
|
|
|
|
return $q.all([ContainerService.createContainer(config), networks]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function connectContainerToOtherNetworks(createContainerData) {
|
|
|
|
var newContainer = createContainerData[0];
|
|
|
|
var networks = createContainerData[1];
|
|
|
|
var networksNames = Object.keys(networks);
|
|
|
|
var connectionPromises = networksNames.map(function connectToNetwork(name) {
|
|
|
|
NetworkService.connectContainer(name, newContainer.Id);
|
|
|
|
});
|
|
|
|
return $q.all(connectionPromises).then(function onConnectToNetworkSuccess() {
|
2018-08-13 19:13:43 +00:00
|
|
|
return newContainer;
|
2017-08-13 10:55:52 +00:00
|
|
|
});
|
2020-04-10 21:54:53 +00:00
|
|
|
}
|
2018-08-13 19:13:43 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function deleteOldContainer(newContainer) {
|
|
|
|
return ContainerService.remove(container, true).then(function onRemoveSuccess() {
|
2018-08-13 19:13:43 +00:00
|
|
|
return newContainer;
|
2020-04-10 21:54:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function startContainerIfNeeded(newContainer) {
|
|
|
|
if (!isRunning) {
|
|
|
|
return $q.when(newContainer);
|
2018-08-13 19:13:43 +00:00
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
return ContainerService.startContainer(newContainer.Id).then(function onStartSuccess() {
|
|
|
|
return newContainer;
|
|
|
|
});
|
|
|
|
}
|
2018-08-13 19:13:43 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function createResourceControl(newContainer) {
|
|
|
|
const userId = Authentication.getUserDetails().ID;
|
|
|
|
const oldResourceControl = container.ResourceControl;
|
|
|
|
const newResourceControl = newContainer.Portainer.ResourceControl;
|
|
|
|
return ResourceControlService.duplicateResourceControl(userId, oldResourceControl, newResourceControl);
|
2017-08-13 10:55:52 +00:00
|
|
|
}
|
2018-08-13 19:13:43 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function notifyAndChangeView() {
|
2022-08-10 05:07:35 +00:00
|
|
|
Notifications.success('Success', 'Container successfully re-created');
|
2020-04-10 21:54:53 +00:00
|
|
|
$state.go('docker.containers', {}, { reload: true });
|
|
|
|
}
|
2018-08-13 19:13:43 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function notifyOnError(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to re-create container');
|
|
|
|
$scope.state.recreateContainerInProgress = false;
|
|
|
|
}
|
2018-08-13 19:13:43 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.recreate = function () {
|
2022-06-30 00:35:32 +00:00
|
|
|
const cannotPullImage = !$scope.container.Config.Image || $scope.container.Config.Image.toLowerCase().startsWith('sha256');
|
|
|
|
ModalService.confirmContainerRecreation(cannotPullImage, function (result) {
|
2020-04-10 21:54:53 +00:00
|
|
|
if (!result) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var pullImage = false;
|
|
|
|
if (result[0]) {
|
|
|
|
pullImage = true;
|
|
|
|
}
|
|
|
|
recreateContainer(pullImage);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
function updateRestartPolicy(restartPolicy, maximumRetryCount) {
|
|
|
|
maximumRetryCount = restartPolicy === 'on-failure' ? maximumRetryCount : undefined;
|
|
|
|
|
|
|
|
return ContainerService.updateRestartPolicy($scope.container.Id, restartPolicy, maximumRetryCount).then(onUpdateSuccess).catch(notifyOnError);
|
|
|
|
|
|
|
|
function onUpdateSuccess() {
|
|
|
|
$scope.container.HostConfig.RestartPolicy = {
|
|
|
|
Name: restartPolicy,
|
|
|
|
MaximumRetryCount: maximumRetryCount,
|
|
|
|
};
|
2022-08-10 05:07:35 +00:00
|
|
|
Notifications.success('Success', 'Restart policy updated');
|
2017-11-07 08:20:59 +00:00
|
|
|
}
|
2018-08-16 09:31:00 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function notifyOnError(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to update restart policy');
|
|
|
|
return $q.reject(err);
|
|
|
|
}
|
2018-08-16 09:31:00 +00:00
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
|
|
|
|
var provider = $scope.applicationState.endpoint.mode.provider;
|
|
|
|
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
|
|
|
NetworkService.networks(provider === 'DOCKER_STANDALONE' || provider === 'DOCKER_SWARM_MODE', false, provider === 'DOCKER_SWARM_MODE' && apiVersion >= 1.25)
|
|
|
|
.then(function success(data) {
|
|
|
|
var networks = data;
|
|
|
|
$scope.availableNetworks = networks;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve networks');
|
|
|
|
});
|
|
|
|
|
|
|
|
update();
|
|
|
|
},
|
|
|
|
]);
|