2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2018-10-28 03:00:56 +00:00
|
|
|
.controller('CreateContainerController', ['$q', '$scope', '$state', '$timeout', '$transition$', '$filter', 'Container', 'ContainerHelper', 'Image', 'ImageHelper', 'Volume', 'NetworkService', 'ResourceControlService', 'Authentication', 'Notifications', 'ContainerService', 'ImageService', 'FormValidator', 'ModalService', 'RegistryService', 'SystemService', 'SettingsService', 'PluginService', 'HttpRequestHelper',
|
|
|
|
function ($q, $scope, $state, $timeout, $transition$, $filter, Container, ContainerHelper, Image, ImageHelper, Volume, NetworkService, ResourceControlService, Authentication, Notifications, ContainerService, ImageService, FormValidator, ModalService, RegistryService, SystemService, SettingsService, PluginService, HttpRequestHelper) {
|
2016-07-06 00:19:09 +00:00
|
|
|
|
2018-08-18 08:27:24 +00:00
|
|
|
$scope.create = create;
|
|
|
|
|
2016-07-06 00:19:09 +00:00
|
|
|
$scope.formValues = {
|
2016-10-20 03:43:09 +00:00
|
|
|
alwaysPull: true,
|
2016-07-06 00:19:09 +00:00
|
|
|
Console: 'none',
|
2016-10-27 06:55:44 +00:00
|
|
|
Volumes: [],
|
2016-12-25 20:33:14 +00:00
|
|
|
NetworkContainer: '',
|
2017-02-15 21:48:40 +00:00
|
|
|
Labels: [],
|
2017-04-25 20:32:27 +00:00
|
|
|
ExtraHosts: [],
|
2018-01-06 10:53:03 +00:00
|
|
|
MacAddress: '',
|
2017-04-25 20:32:27 +00:00
|
|
|
IPv4: '',
|
2017-07-12 07:51:51 +00:00
|
|
|
IPv6: '',
|
2017-10-04 06:39:59 +00:00
|
|
|
AccessControlData: new AccessControlFormData(),
|
|
|
|
CpuLimit: 0,
|
|
|
|
MemoryLimit: 0,
|
2018-05-06 07:15:57 +00:00
|
|
|
MemoryReservation: 0,
|
2018-08-09 08:40:06 +00:00
|
|
|
NodeName: null,
|
2018-10-28 03:00:56 +00:00
|
|
|
capabilities: [],
|
|
|
|
LogDriverName: '',
|
|
|
|
LogDriverOpts: []
|
2016-07-06 00:19:09 +00:00
|
|
|
};
|
|
|
|
|
2018-06-02 06:44:18 +00:00
|
|
|
$scope.extraNetworks = {};
|
|
|
|
|
2017-05-23 18:56:10 +00:00
|
|
|
$scope.state = {
|
2017-11-12 19:27:28 +00:00
|
|
|
formValidationError: '',
|
2017-11-12 21:39:12 +00:00
|
|
|
actionInProgress: false
|
2017-05-23 18:56:10 +00:00
|
|
|
};
|
2016-07-08 03:40:13 +00:00
|
|
|
|
2017-10-04 06:39:59 +00:00
|
|
|
$scope.refreshSlider = function () {
|
|
|
|
$timeout(function () {
|
|
|
|
$scope.$broadcast('rzSliderForceRender');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-07-06 00:19:09 +00:00
|
|
|
$scope.config = {
|
2016-10-27 06:55:44 +00:00
|
|
|
Image: '',
|
|
|
|
Env: [],
|
2017-02-10 05:21:07 +00:00
|
|
|
Cmd: '',
|
2018-01-06 10:53:03 +00:00
|
|
|
MacAddress: '',
|
2016-08-17 07:03:36 +00:00
|
|
|
ExposedPorts: {},
|
2016-07-06 00:19:09 +00:00
|
|
|
HostConfig: {
|
|
|
|
RestartPolicy: {
|
|
|
|
Name: 'no'
|
|
|
|
},
|
2016-10-27 06:55:44 +00:00
|
|
|
PortBindings: [],
|
2017-02-11 23:23:13 +00:00
|
|
|
PublishAllPorts: false,
|
2016-07-06 00:19:09 +00:00
|
|
|
Binds: [],
|
|
|
|
NetworkMode: 'bridge',
|
2017-02-15 21:48:40 +00:00
|
|
|
Privileged: false,
|
2018-08-16 09:28:06 +00:00
|
|
|
Runtime: '',
|
2017-04-16 07:57:47 +00:00
|
|
|
ExtraHosts: [],
|
2018-08-09 08:40:06 +00:00
|
|
|
Devices: [],
|
|
|
|
CapAdd: [],
|
|
|
|
CapDrop: []
|
2016-12-25 20:33:14 +00:00
|
|
|
},
|
2017-04-25 20:32:27 +00:00
|
|
|
NetworkingConfig: {
|
|
|
|
EndpointsConfig: {}
|
|
|
|
},
|
2016-12-25 20:33:14 +00:00
|
|
|
Labels: {}
|
2016-07-06 00:19:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.addVolume = function() {
|
2017-03-27 12:44:39 +00:00
|
|
|
$scope.formValues.Volumes.push({ name: '', containerPath: '', readOnly: false, type: 'volume' });
|
2016-07-06 00:19:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removeVolume = function(index) {
|
|
|
|
$scope.formValues.Volumes.splice(index, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.addEnvironmentVariable = function() {
|
|
|
|
$scope.config.Env.push({ name: '', value: ''});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removeEnvironmentVariable = function(index) {
|
|
|
|
$scope.config.Env.splice(index, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.addPortBinding = function() {
|
|
|
|
$scope.config.HostConfig.PortBindings.push({ hostPort: '', containerPort: '', protocol: 'tcp' });
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removePortBinding = function(index) {
|
|
|
|
$scope.config.HostConfig.PortBindings.splice(index, 1);
|
|
|
|
};
|
|
|
|
|
2016-12-25 20:33:14 +00:00
|
|
|
$scope.addLabel = function() {
|
|
|
|
$scope.formValues.Labels.push({ name: '', value: ''});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removeLabel = function(index) {
|
|
|
|
$scope.formValues.Labels.splice(index, 1);
|
|
|
|
};
|
|
|
|
|
2017-02-15 21:48:40 +00:00
|
|
|
$scope.addExtraHost = function() {
|
|
|
|
$scope.formValues.ExtraHosts.push({ value: '' });
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removeExtraHost = function(index) {
|
|
|
|
$scope.formValues.ExtraHosts.splice(index, 1);
|
|
|
|
};
|
2017-05-23 18:56:10 +00:00
|
|
|
|
2017-04-16 07:57:47 +00:00
|
|
|
$scope.addDevice = function() {
|
|
|
|
$scope.config.HostConfig.Devices.push({ pathOnHost: '', pathInContainer: '' });
|
|
|
|
};
|
2017-02-15 21:48:40 +00:00
|
|
|
|
2017-04-16 07:57:47 +00:00
|
|
|
$scope.removeDevice = function(index) {
|
|
|
|
$scope.config.HostConfig.Devices.splice(index, 1);
|
|
|
|
};
|
2017-02-15 21:48:40 +00:00
|
|
|
|
2018-10-28 03:00:56 +00:00
|
|
|
$scope.addLogDriverOpt = function() {
|
|
|
|
$scope.formValues.LogDriverOpts.push({ name: '', value: ''});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.removeLogDriverOpt = function(index) {
|
|
|
|
$scope.formValues.LogDriverOpts.splice(index, 1);
|
|
|
|
};
|
|
|
|
|
2017-08-13 10:17:41 +00:00
|
|
|
$scope.fromContainerMultipleNetworks = false;
|
|
|
|
|
2016-07-08 03:31:09 +00:00
|
|
|
function prepareImageConfig(config) {
|
2016-12-31 00:25:42 +00:00
|
|
|
var image = config.Image;
|
2016-07-08 03:31:09 +00:00
|
|
|
var registry = $scope.formValues.Registry;
|
2017-06-20 11:00:32 +00:00
|
|
|
var imageConfig = ImageHelper.createImageConfigForContainer(image, registry.URL);
|
2016-07-08 03:31:09 +00:00
|
|
|
config.Image = imageConfig.fromImage + ':' + imageConfig.tag;
|
|
|
|
$scope.imageConfig = imageConfig;
|
|
|
|
}
|
|
|
|
|
2016-07-06 00:19:09 +00:00
|
|
|
function preparePortBindings(config) {
|
|
|
|
var bindings = {};
|
|
|
|
config.HostConfig.PortBindings.forEach(function (portBinding) {
|
2016-10-07 05:08:07 +00:00
|
|
|
if (portBinding.containerPort) {
|
2017-05-23 18:56:10 +00:00
|
|
|
var key = portBinding.containerPort + '/' + portBinding.protocol;
|
2016-08-17 07:31:06 +00:00
|
|
|
var binding = {};
|
2016-10-07 05:08:07 +00:00
|
|
|
if (portBinding.hostPort && portBinding.hostPort.indexOf(':') > -1) {
|
2016-08-17 07:31:06 +00:00
|
|
|
var hostAndPort = portBinding.hostPort.split(':');
|
|
|
|
binding.HostIp = hostAndPort[0];
|
|
|
|
binding.HostPort = hostAndPort[1];
|
|
|
|
} else {
|
|
|
|
binding.HostPort = portBinding.hostPort;
|
|
|
|
}
|
|
|
|
bindings[key] = [binding];
|
2016-08-17 07:03:36 +00:00
|
|
|
config.ExposedPorts[key] = {};
|
2016-07-06 00:19:09 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
config.HostConfig.PortBindings = bindings;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepareConsole(config) {
|
|
|
|
var value = $scope.formValues.Console;
|
|
|
|
var openStdin = true;
|
|
|
|
var tty = true;
|
|
|
|
if (value === 'tty') {
|
|
|
|
openStdin = false;
|
|
|
|
} else if (value === 'interactive') {
|
|
|
|
tty = false;
|
|
|
|
} else if (value === 'none') {
|
|
|
|
openStdin = false;
|
|
|
|
tty = false;
|
|
|
|
}
|
|
|
|
config.OpenStdin = openStdin;
|
|
|
|
config.Tty = tty;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepareEnvironmentVariables(config) {
|
|
|
|
var env = [];
|
|
|
|
config.Env.forEach(function (v) {
|
|
|
|
if (v.name && v.value) {
|
2017-05-23 18:56:10 +00:00
|
|
|
env.push(v.name + '=' + v.value);
|
2016-07-06 00:19:09 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
config.Env = env;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepareVolumes(config) {
|
|
|
|
var binds = [];
|
|
|
|
var volumes = {};
|
|
|
|
|
|
|
|
$scope.formValues.Volumes.forEach(function (volume) {
|
|
|
|
var name = volume.name;
|
|
|
|
var containerPath = volume.containerPath;
|
|
|
|
if (name && containerPath) {
|
|
|
|
var bind = name + ':' + containerPath;
|
|
|
|
volumes[containerPath] = {};
|
|
|
|
if (volume.readOnly) {
|
|
|
|
bind += ':ro';
|
|
|
|
}
|
|
|
|
binds.push(bind);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
config.HostConfig.Binds = binds;
|
|
|
|
config.Volumes = volumes;
|
|
|
|
}
|
|
|
|
|
2016-11-16 01:52:05 +00:00
|
|
|
function prepareNetworkConfig(config) {
|
|
|
|
var mode = config.HostConfig.NetworkMode;
|
|
|
|
var container = $scope.formValues.NetworkContainer;
|
|
|
|
var containerName = container;
|
|
|
|
if (container && typeof container === 'object') {
|
|
|
|
containerName = $filter('trimcontainername')(container.Names[0]);
|
|
|
|
}
|
|
|
|
var networkMode = mode;
|
|
|
|
if (containerName) {
|
|
|
|
networkMode += ':' + containerName;
|
2017-08-13 10:17:41 +00:00
|
|
|
config.Hostname = '';
|
2016-11-16 01:52:05 +00:00
|
|
|
}
|
|
|
|
config.HostConfig.NetworkMode = networkMode;
|
2018-01-06 10:53:03 +00:00
|
|
|
config.MacAddress = $scope.formValues.MacAddress;
|
2017-03-12 16:24:15 +00:00
|
|
|
|
2017-04-25 20:32:27 +00:00
|
|
|
config.NetworkingConfig.EndpointsConfig[networkMode] = {
|
|
|
|
IPAMConfig: {
|
|
|
|
IPv4Address: $scope.formValues.IPv4,
|
|
|
|
IPv6Address: $scope.formValues.IPv6
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-15 21:48:40 +00:00
|
|
|
$scope.formValues.ExtraHosts.forEach(function (v) {
|
|
|
|
if (v.value) {
|
|
|
|
config.HostConfig.ExtraHosts.push(v.value);
|
|
|
|
}
|
|
|
|
});
|
2016-11-16 01:52:05 +00:00
|
|
|
}
|
|
|
|
|
2016-12-25 20:33:14 +00:00
|
|
|
function prepareLabels(config) {
|
|
|
|
var labels = {};
|
|
|
|
$scope.formValues.Labels.forEach(function (label) {
|
|
|
|
if (label.name && label.value) {
|
|
|
|
labels[label.name] = label.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
config.Labels = labels;
|
|
|
|
}
|
2017-05-23 18:56:10 +00:00
|
|
|
|
2017-04-16 07:57:47 +00:00
|
|
|
function prepareDevices(config) {
|
|
|
|
var path = [];
|
|
|
|
config.HostConfig.Devices.forEach(function (p) {
|
|
|
|
if (p.pathOnHost) {
|
|
|
|
if(p.pathInContainer === '') {
|
|
|
|
p.pathInContainer = p.pathOnHost;
|
|
|
|
}
|
2017-05-23 18:56:10 +00:00
|
|
|
path.push({PathOnHost:p.pathOnHost,PathInContainer:p.pathInContainer,CgroupPermissions:'rwm'});
|
2017-04-16 07:57:47 +00:00
|
|
|
}
|
|
|
|
});
|
2017-05-23 18:56:10 +00:00
|
|
|
config.HostConfig.Devices = path;
|
2017-04-16 07:57:47 +00:00
|
|
|
}
|
2016-12-25 20:33:14 +00:00
|
|
|
|
2017-10-04 06:39:59 +00:00
|
|
|
function prepareResources(config) {
|
|
|
|
// Memory Limit - Round to 0.125
|
|
|
|
var memoryLimit = (Math.round($scope.formValues.MemoryLimit * 8) / 8).toFixed(3);
|
|
|
|
memoryLimit *= 1024 * 1024;
|
|
|
|
if (memoryLimit > 0) {
|
|
|
|
config.HostConfig.Memory = memoryLimit;
|
|
|
|
}
|
|
|
|
// Memory Resevation - Round to 0.125
|
|
|
|
var memoryReservation = (Math.round($scope.formValues.MemoryReservation * 8) / 8).toFixed(3);
|
|
|
|
memoryReservation *= 1024 * 1024;
|
|
|
|
if (memoryReservation > 0) {
|
|
|
|
config.HostConfig.MemoryReservation = memoryReservation;
|
|
|
|
}
|
|
|
|
// CPU Limit
|
|
|
|
if ($scope.formValues.CpuLimit > 0) {
|
|
|
|
config.HostConfig.NanoCpus = $scope.formValues.CpuLimit * 1000000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-28 03:00:56 +00:00
|
|
|
function prepareLogDriver(config) {
|
|
|
|
var logOpts = {};
|
|
|
|
if ($scope.formValues.LogDriverName) {
|
|
|
|
config.HostConfig.LogConfig = { Type: $scope.formValues.LogDriverName };
|
|
|
|
if ($scope.formValues.LogDriverName !== 'none') {
|
|
|
|
$scope.formValues.LogDriverOpts.forEach(function (opt) {
|
|
|
|
if (opt.name) {
|
|
|
|
logOpts[opt.name] = opt.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (Object.keys(logOpts).length !== 0 && logOpts.constructor === Object) {
|
|
|
|
config.HostConfig.LogConfig.Config = logOpts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-09 08:40:06 +00:00
|
|
|
function prepareCapabilities(config) {
|
|
|
|
var allowed = $scope.formValues.capabilities.filter(function(item) {return item.allowed === true;});
|
|
|
|
var notAllowed = $scope.formValues.capabilities.filter(function(item) {return item.allowed === false;});
|
|
|
|
|
|
|
|
var getCapName = function(item) {return item.capability;};
|
|
|
|
config.HostConfig.CapAdd = allowed.map(getCapName);
|
|
|
|
config.HostConfig.CapDrop = notAllowed.map(getCapName);
|
|
|
|
}
|
|
|
|
|
2016-07-06 00:19:09 +00:00
|
|
|
function prepareConfiguration() {
|
|
|
|
var config = angular.copy($scope.config);
|
2017-02-10 05:21:07 +00:00
|
|
|
config.Cmd = ContainerHelper.commandStringToArray(config.Cmd);
|
2016-11-16 01:52:05 +00:00
|
|
|
prepareNetworkConfig(config);
|
2016-07-08 03:31:09 +00:00
|
|
|
prepareImageConfig(config);
|
2016-07-06 00:19:09 +00:00
|
|
|
preparePortBindings(config);
|
|
|
|
prepareConsole(config);
|
|
|
|
prepareEnvironmentVariables(config);
|
|
|
|
prepareVolumes(config);
|
2016-12-25 20:33:14 +00:00
|
|
|
prepareLabels(config);
|
2017-04-16 07:57:47 +00:00
|
|
|
prepareDevices(config);
|
2017-10-04 06:39:59 +00:00
|
|
|
prepareResources(config);
|
2018-10-28 03:00:56 +00:00
|
|
|
prepareLogDriver(config);
|
2018-08-09 08:40:06 +00:00
|
|
|
prepareCapabilities(config);
|
2016-07-06 00:19:09 +00:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
|
|
|
|
function loadFromContainerCmd() {
|
2017-08-13 10:17:41 +00:00
|
|
|
if ($scope.config.Cmd) {
|
|
|
|
$scope.config.Cmd = ContainerHelper.commandArrayToString($scope.config.Cmd);
|
|
|
|
} else {
|
|
|
|
$scope.config.Cmd = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
function loadFromContainerPortBindings() {
|
2017-08-13 10:17:41 +00:00
|
|
|
var bindings = [];
|
|
|
|
for (var p in $scope.config.HostConfig.PortBindings) {
|
|
|
|
if ({}.hasOwnProperty.call($scope.config.HostConfig.PortBindings, p)) {
|
2018-06-02 06:44:18 +00:00
|
|
|
var hostPort = '';
|
2017-08-13 10:17:41 +00:00
|
|
|
if ($scope.config.HostConfig.PortBindings[p][0].HostIp) {
|
|
|
|
hostPort = $scope.config.HostConfig.PortBindings[p][0].HostIp + ':';
|
|
|
|
}
|
|
|
|
hostPort += $scope.config.HostConfig.PortBindings[p][0].HostPort;
|
|
|
|
var b = {
|
|
|
|
'hostPort': hostPort,
|
|
|
|
'containerPort': p.split('/')[0],
|
|
|
|
'protocol': p.split('/')[1]
|
|
|
|
};
|
|
|
|
bindings.push(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$scope.config.HostConfig.PortBindings = bindings;
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadFromContainerVolumes(d) {
|
|
|
|
for (var v in d.Mounts) {
|
|
|
|
if ({}.hasOwnProperty.call(d.Mounts, v)) {
|
|
|
|
var mount = d.Mounts[v];
|
|
|
|
var volume = {
|
|
|
|
'type': mount.Type,
|
|
|
|
'name': mount.Name || mount.Source,
|
|
|
|
'containerPath': mount.Destination,
|
|
|
|
'readOnly': mount.RW === false
|
|
|
|
};
|
|
|
|
$scope.formValues.Volumes.push(volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-23 15:02:40 +00:00
|
|
|
$scope.resetNetworkConfig = function() {
|
|
|
|
$scope.config.NetworkingConfig = {
|
|
|
|
EndpointsConfig: {}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-08-13 10:17:41 +00:00
|
|
|
function loadFromContainerNetworkConfig(d) {
|
|
|
|
$scope.config.NetworkingConfig = {
|
|
|
|
EndpointsConfig: {}
|
|
|
|
};
|
|
|
|
var networkMode = d.HostConfig.NetworkMode;
|
|
|
|
if (networkMode === 'default') {
|
|
|
|
$scope.config.HostConfig.NetworkMode = 'bridge';
|
|
|
|
if (!_.find($scope.availableNetworks, {'Name': 'bridge'})) {
|
|
|
|
$scope.config.HostConfig.NetworkMode = 'nat';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($scope.config.HostConfig.NetworkMode.indexOf('container:') === 0) {
|
|
|
|
var netContainer = $scope.config.HostConfig.NetworkMode.split(/^container:/)[1];
|
|
|
|
$scope.config.HostConfig.NetworkMode = 'container';
|
|
|
|
for (var c in $scope.runningContainers) {
|
|
|
|
if ($scope.runningContainers[c].Names && $scope.runningContainers[c].Names[0] === '/' + netContainer) {
|
|
|
|
$scope.formValues.NetworkContainer = $scope.runningContainers[c];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$scope.fromContainerMultipleNetworks = Object.keys(d.NetworkSettings.Networks).length >= 2;
|
|
|
|
if (d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode]) {
|
|
|
|
if (d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode].IPAMConfig) {
|
|
|
|
if (d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode].IPAMConfig.IPv4Address) {
|
|
|
|
$scope.formValues.IPv4 = d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode].IPAMConfig.IPv4Address;
|
|
|
|
}
|
|
|
|
if (d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode].IPAMConfig.IPv6Address) {
|
|
|
|
$scope.formValues.IPv6 = d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode].IPAMConfig.IPv6Address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$scope.config.NetworkingConfig.EndpointsConfig[$scope.config.HostConfig.NetworkMode] = d.NetworkSettings.Networks[$scope.config.HostConfig.NetworkMode];
|
2018-01-06 10:53:03 +00:00
|
|
|
// Mac Address
|
2018-06-02 06:44:18 +00:00
|
|
|
if(Object.keys(d.NetworkSettings.Networks).length) {
|
|
|
|
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 = '';
|
|
|
|
}
|
2018-08-20 18:55:12 +00:00
|
|
|
|
2017-08-13 10:17:41 +00:00
|
|
|
// ExtraHosts
|
2018-05-06 07:15:57 +00:00
|
|
|
if ($scope.config.HostConfig.ExtraHosts) {
|
|
|
|
var extraHosts = $scope.config.HostConfig.ExtraHosts;
|
|
|
|
for (var i = 0; i < extraHosts.length; i++) {
|
|
|
|
var host = extraHosts[i];
|
|
|
|
$scope.formValues.ExtraHosts.push({ 'value': host });
|
|
|
|
}
|
|
|
|
$scope.config.HostConfig.ExtraHosts = [];
|
2017-08-13 10:17:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
function loadFromContainerEnvironmentVariables() {
|
2017-08-13 10:17:41 +00:00
|
|
|
var envArr = [];
|
|
|
|
for (var e in $scope.config.Env) {
|
|
|
|
if ({}.hasOwnProperty.call($scope.config.Env, e)) {
|
|
|
|
var arr = $scope.config.Env[e].split(/\=(.+)/);
|
|
|
|
envArr.push({'name': arr[0], 'value': arr[1]});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$scope.config.Env = envArr;
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
function loadFromContainerLabels() {
|
2017-08-13 10:17:41 +00:00
|
|
|
for (var l in $scope.config.Labels) {
|
|
|
|
if ({}.hasOwnProperty.call($scope.config.Labels, l)) {
|
|
|
|
$scope.formValues.Labels.push({ name: l, value: $scope.config.Labels[l]});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
function loadFromContainerConsole() {
|
2017-08-13 10:17:41 +00:00
|
|
|
if ($scope.config.OpenStdin && $scope.config.Tty) {
|
|
|
|
$scope.formValues.Console = 'both';
|
|
|
|
} else if (!$scope.config.OpenStdin && $scope.config.Tty) {
|
|
|
|
$scope.formValues.Console = 'tty';
|
|
|
|
} else if ($scope.config.OpenStdin && !$scope.config.Tty) {
|
|
|
|
$scope.formValues.Console = 'interactive';
|
|
|
|
} else if (!$scope.config.OpenStdin && !$scope.config.Tty) {
|
|
|
|
$scope.formValues.Console = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
function loadFromContainerDevices() {
|
2017-08-13 10:17:41 +00:00
|
|
|
var path = [];
|
|
|
|
for (var dev in $scope.config.HostConfig.Devices) {
|
|
|
|
if ({}.hasOwnProperty.call($scope.config.HostConfig.Devices, dev)) {
|
|
|
|
var device = $scope.config.HostConfig.Devices[dev];
|
|
|
|
path.push({'pathOnHost': device.PathOnHost, 'pathInContainer': device.PathInContainer});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$scope.config.HostConfig.Devices = path;
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
function loadFromContainerImageConfig() {
|
2017-08-13 10:17:41 +00:00
|
|
|
var imageInfo = ImageHelper.extractImageAndRegistryFromRepository($scope.config.Image);
|
|
|
|
RegistryService.retrieveRegistryFromRepository($scope.config.Image)
|
|
|
|
.then(function success(data) {
|
|
|
|
if (data) {
|
|
|
|
$scope.config.Image = imageInfo.image;
|
|
|
|
$scope.formValues.Registry = data;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrive registry');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-04 06:39:59 +00:00
|
|
|
function loadFromContainerResources(d) {
|
|
|
|
if (d.HostConfig.NanoCpus) {
|
|
|
|
$scope.formValues.CpuLimit = d.HostConfig.NanoCpus / 1000000000;
|
|
|
|
}
|
|
|
|
if (d.HostConfig.Memory) {
|
|
|
|
$scope.formValues.MemoryLimit = d.HostConfig.Memory / 1024 / 1024;
|
|
|
|
}
|
|
|
|
if (d.HostConfig.MemoryReservation) {
|
|
|
|
$scope.formValues.MemoryReservation = d.HostConfig.MemoryReservation / 1024 / 1024;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-09 08:40:06 +00:00
|
|
|
function loadFromContainerCapabilities(d) {
|
|
|
|
if (d.HostConfig.CapAdd) {
|
|
|
|
d.HostConfig.CapAdd.forEach(function(cap) {
|
|
|
|
$scope.formValues.capabilities.push(new ContainerCapability(cap, true));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (d.HostConfig.CapDrop) {
|
|
|
|
d.HostConfig.CapDrop.forEach(function(cap) {
|
|
|
|
$scope.formValues.capabilities.push(new ContainerCapability(cap, false));
|
|
|
|
});
|
|
|
|
}
|
2019-01-22 20:28:44 +00:00
|
|
|
|
|
|
|
function hasCapability(item) {
|
|
|
|
return item.capability === cap.capability;
|
|
|
|
}
|
|
|
|
|
|
|
|
var capabilities = new ContainerCapabilities();
|
|
|
|
for (var i = 0; i < capabilities.length; i++) {
|
|
|
|
var cap = capabilities[i];
|
|
|
|
if (!_.find($scope.formValues.capabilities, hasCapability)) {
|
|
|
|
$scope.formValues.capabilities.push(cap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-09 08:40:06 +00:00
|
|
|
$scope.formValues.capabilities.sort(function(a, b) {
|
|
|
|
return a.capability < b.capability ? -1 : 1;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-08-13 10:17:41 +00:00
|
|
|
function loadFromContainerSpec() {
|
|
|
|
// Get container
|
2017-09-21 14:00:53 +00:00
|
|
|
Container.get({ id: $transition$.params().from }).$promise
|
2017-08-13 10:17:41 +00:00
|
|
|
.then(function success(d) {
|
|
|
|
var fromContainer = new ContainerDetailsViewModel(d);
|
2018-08-20 19:06:30 +00:00
|
|
|
if (fromContainer.ResourceControl && fromContainer.ResourceControl.Public) {
|
2017-08-13 10:17:41 +00:00
|
|
|
$scope.formValues.AccessControlData.AccessControlEnabled = false;
|
|
|
|
}
|
|
|
|
$scope.fromContainer = fromContainer;
|
|
|
|
$scope.config = ContainerHelper.configFromContainer(fromContainer.Model);
|
|
|
|
loadFromContainerCmd(d);
|
2019-01-16 00:34:28 +00:00
|
|
|
loadFromContainerLogging(d);
|
2017-08-13 10:17:41 +00:00
|
|
|
loadFromContainerPortBindings(d);
|
|
|
|
loadFromContainerVolumes(d);
|
|
|
|
loadFromContainerNetworkConfig(d);
|
2018-01-06 10:53:03 +00:00
|
|
|
loadFromContainerEnvironmentVariables(d);
|
2017-08-13 10:17:41 +00:00
|
|
|
loadFromContainerLabels(d);
|
|
|
|
loadFromContainerConsole(d);
|
|
|
|
loadFromContainerDevices(d);
|
|
|
|
loadFromContainerImageConfig(d);
|
2017-10-04 06:39:59 +00:00
|
|
|
loadFromContainerResources(d);
|
2018-08-09 08:40:06 +00:00
|
|
|
loadFromContainerCapabilities(d);
|
2017-08-13 10:17:41 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve container');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:34:28 +00:00
|
|
|
function loadFromContainerLogging(config) {
|
|
|
|
var logConfig = config.HostConfig.LogConfig;
|
|
|
|
$scope.formValues.LogDriverName = logConfig.Type;
|
|
|
|
$scope.formValues.LogDriverOpts = _.map(logConfig.Config, function (value, name) {
|
|
|
|
return {
|
|
|
|
name: name,
|
|
|
|
value: value
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-23 18:56:10 +00:00
|
|
|
function initView() {
|
2018-05-06 07:15:57 +00:00
|
|
|
var nodeName = $transition$.params().nodeName;
|
|
|
|
$scope.formValues.NodeName = nodeName;
|
|
|
|
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
|
|
|
|
|
2017-06-01 08:14:55 +00:00
|
|
|
Volume.query({}, function (d) {
|
|
|
|
$scope.availableVolumes = d.Volumes;
|
|
|
|
}, function (e) {
|
|
|
|
Notifications.error('Failure', e, 'Unable to retrieve volumes');
|
2017-05-23 18:56:10 +00:00
|
|
|
});
|
2017-06-01 08:14:55 +00:00
|
|
|
|
2017-08-11 07:46:55 +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,
|
2018-04-04 00:31:04 +00:00
|
|
|
provider === 'DOCKER_SWARM_MODE' && apiVersion >= 1.25
|
2017-08-11 07:46:55 +00:00
|
|
|
)
|
|
|
|
.then(function success(data) {
|
|
|
|
var networks = data;
|
|
|
|
networks.push({ Name: 'container' });
|
2017-06-01 08:14:55 +00:00
|
|
|
$scope.availableNetworks = networks;
|
2017-08-11 07:46:55 +00:00
|
|
|
|
|
|
|
if (_.find(networks, {'Name': 'nat'})) {
|
2017-06-01 08:14:55 +00:00
|
|
|
$scope.config.HostConfig.NetworkMode = 'nat';
|
|
|
|
}
|
2017-08-11 07:46:55 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve networks');
|
2017-06-01 08:14:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Container.query({}, function (d) {
|
|
|
|
var containers = d;
|
|
|
|
$scope.runningContainers = containers;
|
2018-05-06 07:15:57 +00:00
|
|
|
if ($transition$.params().from) {
|
2017-08-13 10:17:41 +00:00
|
|
|
loadFromContainerSpec();
|
|
|
|
} else {
|
|
|
|
$scope.fromContainer = {};
|
|
|
|
$scope.formValues.Registry = {};
|
2018-08-09 08:40:06 +00:00
|
|
|
$scope.formValues.capabilities = new ContainerCapabilities();
|
2017-08-13 10:17:41 +00:00
|
|
|
}
|
2017-06-01 08:14:55 +00:00
|
|
|
}, function(e) {
|
|
|
|
Notifications.error('Failure', e, 'Unable to retrieve running containers');
|
|
|
|
});
|
|
|
|
|
2017-10-04 06:39:59 +00:00
|
|
|
SystemService.info()
|
|
|
|
.then(function success(data) {
|
2018-10-08 20:28:26 +00:00
|
|
|
$scope.availableRuntimes = Object.keys(data.Runtimes);
|
|
|
|
$scope.config.HostConfig.Runtime = '';
|
2017-10-04 06:39:59 +00:00
|
|
|
$scope.state.sliderMaxCpu = 32;
|
|
|
|
if (data.NCPU) {
|
|
|
|
$scope.state.sliderMaxCpu = data.NCPU;
|
|
|
|
}
|
|
|
|
$scope.state.sliderMaxMemory = 32768;
|
|
|
|
if (data.MemTotal) {
|
|
|
|
$scope.state.sliderMaxMemory = Math.floor(data.MemTotal / 1000 / 1000);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve engine details');
|
|
|
|
});
|
|
|
|
|
2017-09-26 03:36:51 +00:00
|
|
|
SettingsService.publicSettings()
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.allowBindMounts = data.AllowBindMountsForRegularUsers;
|
2017-09-27 07:26:04 +00:00
|
|
|
$scope.allowPrivilegedMode = data.AllowPrivilegedModeForRegularUsers;
|
2017-09-26 03:36:51 +00:00
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve application settings');
|
|
|
|
});
|
|
|
|
|
2018-10-28 03:00:56 +00:00
|
|
|
PluginService.loggingPlugins(apiVersion < 1.25)
|
|
|
|
.then(function success(loggingDrivers) {
|
|
|
|
$scope.availableLoggingDrivers = loggingDrivers;
|
|
|
|
});
|
|
|
|
|
2017-09-26 03:36:51 +00:00
|
|
|
var userDetails = Authentication.getUserDetails();
|
2017-11-14 07:54:35 +00:00
|
|
|
$scope.isAdmin = userDetails.role === 1;
|
2017-05-23 18:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function validateForm(accessControlData, isAdmin) {
|
|
|
|
$scope.state.formValidationError = '';
|
|
|
|
var error = '';
|
|
|
|
error = FormValidator.validateAccessControl(accessControlData, isAdmin);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
$scope.state.formValidationError = error;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-12 19:27:28 +00:00
|
|
|
|
2018-08-18 08:27:24 +00:00
|
|
|
function create() {
|
|
|
|
var oldContainer = null;
|
2017-05-23 18:56:10 +00:00
|
|
|
|
2018-08-18 08:27:24 +00:00
|
|
|
HttpRequestHelper.setPortainerAgentTargetHeader($scope.formValues.NodeName);
|
|
|
|
return findCurrentContainer()
|
2019-01-17 19:59:43 +00:00
|
|
|
.then(setOldContainer)
|
2018-08-18 08:27:24 +00:00
|
|
|
.then(confirmCreateContainer)
|
|
|
|
.then(startCreationProcess)
|
|
|
|
.catch(notifyOnError)
|
|
|
|
.finally(final);
|
|
|
|
|
|
|
|
function final() {
|
|
|
|
$scope.state.actionInProgress = false;
|
|
|
|
}
|
|
|
|
|
2019-01-17 19:59:43 +00:00
|
|
|
function setOldContainer(container) {
|
|
|
|
oldContainer = container;
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
2018-08-18 08:27:24 +00:00
|
|
|
function findCurrentContainer() {
|
|
|
|
return Container.query({ all: 1, filters: { name: ['^/' + $scope.config.name + '$'] } })
|
|
|
|
.$promise
|
|
|
|
.then(function onQuerySuccess(containers) {
|
|
|
|
if (!containers.length) {
|
|
|
|
return;
|
|
|
|
}
|
2019-01-17 19:59:43 +00:00
|
|
|
return containers[0];
|
2018-08-18 08:27:24 +00:00
|
|
|
})
|
|
|
|
.catch(notifyOnError);
|
|
|
|
|
|
|
|
function notifyOnError(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve containers');
|
2017-08-13 10:17:41 +00:00
|
|
|
}
|
2018-08-18 08:27:24 +00:00
|
|
|
}
|
2017-05-23 18:56:10 +00:00
|
|
|
|
2018-08-18 08:27:24 +00:00
|
|
|
function startCreationProcess(confirmed) {
|
|
|
|
if (!confirmed) {
|
|
|
|
return $q.when();
|
|
|
|
}
|
|
|
|
if (!validateAccessControl()) {
|
|
|
|
return $q.when();
|
|
|
|
}
|
2017-11-12 21:39:12 +00:00
|
|
|
$scope.state.actionInProgress = true;
|
2018-08-20 18:55:12 +00:00
|
|
|
return pullImageIfNeeded()
|
2018-12-20 15:37:35 +00:00
|
|
|
.then(stopAndRenameContainer)
|
2018-08-18 08:27:24 +00:00
|
|
|
.then(createNewContainer)
|
|
|
|
.then(applyResourceControl)
|
|
|
|
.then(connectToExtraNetworks)
|
|
|
|
.then(removeOldContainer)
|
2019-01-17 19:59:43 +00:00
|
|
|
.then(onSuccess)
|
|
|
|
.catch(onCreationProcessFail);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCreationProcessFail(error) {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
removeNewContainer()
|
|
|
|
.then(restoreOldContainerName)
|
|
|
|
.then(function() {
|
|
|
|
deferred.reject(error);
|
|
|
|
})
|
|
|
|
.catch(function(restoreError) {
|
|
|
|
deferred.reject(restoreError);
|
|
|
|
});
|
|
|
|
return deferred.promise;
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeNewContainer() {
|
|
|
|
return findCurrentContainer().then(function onContainerLoaded(container) {
|
|
|
|
if (container && (!oldContainer || container.Id !== oldContainer.Id)) {
|
|
|
|
return ContainerService.remove(container, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function restoreOldContainerName() {
|
|
|
|
if (!oldContainer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return ContainerService.renameContainer(oldContainer.Id, oldContainer.Names[0].substring(1));
|
2018-08-18 08:27:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function confirmCreateContainer(container) {
|
|
|
|
if (!container) {
|
|
|
|
return $q.when(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return showConfirmationModal();
|
|
|
|
|
|
|
|
function showConfirmationModal() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
|
|
|
ModalService.confirm({
|
|
|
|
title: 'Are you sure ?',
|
|
|
|
message: 'A container with the same name already exists. Portainer can automatically remove it and re-create one. Do you want to replace it?',
|
|
|
|
buttons: {
|
|
|
|
confirm: {
|
|
|
|
label: 'Replace',
|
|
|
|
className: 'btn-danger'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
callback: function onConfirm(confirmed) {
|
|
|
|
deferred.resolve(confirmed);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:37:35 +00:00
|
|
|
function stopAndRenameContainer() {
|
2018-08-18 08:27:24 +00:00
|
|
|
if (!oldContainer) {
|
|
|
|
return $q.when();
|
|
|
|
}
|
|
|
|
return stopContainerIfNeeded(oldContainer)
|
|
|
|
.then(renameContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stopContainerIfNeeded(oldContainer) {
|
|
|
|
if (oldContainer.State !== 'running') {
|
|
|
|
return $q.when();
|
|
|
|
}
|
|
|
|
return ContainerService.stopContainer(oldContainer.Id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function renameContainer() {
|
|
|
|
return ContainerService.renameContainer(oldContainer.Id, oldContainer.Names[0].substring(1) + '-old');
|
|
|
|
}
|
|
|
|
|
|
|
|
function pullImageIfNeeded() {
|
|
|
|
return $q.when($scope.formValues.alwaysPull &&
|
|
|
|
ImageService.pullImage($scope.config.Image, $scope.formValues.Registry, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
function createNewContainer() {
|
2017-08-13 10:17:41 +00:00
|
|
|
var config = prepareConfiguration();
|
2018-08-18 08:27:24 +00:00
|
|
|
return ContainerService.createAndStartContainer(config);
|
|
|
|
}
|
2017-05-23 18:56:10 +00:00
|
|
|
|
2018-08-18 08:27:24 +00:00
|
|
|
function applyResourceControl(newContainer) {
|
|
|
|
var containerIdentifier = newContainer.Id;
|
|
|
|
var userId = Authentication.getUserDetails().ID;
|
|
|
|
|
|
|
|
return $q.when(ResourceControlService.applyResourceControl(
|
|
|
|
'container',
|
|
|
|
containerIdentifier,
|
|
|
|
userId,
|
|
|
|
$scope.formValues.AccessControlData, []
|
|
|
|
)).then(function onApplyResourceControlSuccess() {
|
|
|
|
return containerIdentifier;
|
2017-06-05 05:55:18 +00:00
|
|
|
});
|
2018-08-18 08:27:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function connectToExtraNetworks(newContainerId) {
|
|
|
|
if (!$scope.extraNetworks) {
|
|
|
|
return $q.when();
|
|
|
|
}
|
|
|
|
|
|
|
|
var connectionPromises = Object.keys($scope.extraNetworks).map(function (networkName) {
|
|
|
|
return NetworkService.connectContainer(networkName, newContainerId);
|
|
|
|
});
|
|
|
|
|
|
|
|
return $q.all(connectionPromises);
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeOldContainer() {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
|
|
|
if (!oldContainer) {
|
|
|
|
deferred.resolve();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ContainerService.remove(oldContainer, true)
|
|
|
|
.then(notifyOnRemoval)
|
|
|
|
.catch(notifyOnRemoveError);
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
|
|
|
|
function notifyOnRemoval() {
|
|
|
|
Notifications.success('Container Removed', oldContainer.Id);
|
|
|
|
deferred.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
function notifyOnRemoveError(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to remove container', err: err });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function notifyOnError(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to create container');
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateAccessControl() {
|
|
|
|
var accessControlData = $scope.formValues.AccessControlData;
|
|
|
|
var userDetails = Authentication.getUserDetails();
|
|
|
|
var isAdmin = userDetails.role === 1;
|
|
|
|
|
|
|
|
return validateForm(accessControlData, isAdmin);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSuccess() {
|
|
|
|
Notifications.success('Container successfully created');
|
|
|
|
$state.go('docker.containers', {}, { reload: true });
|
|
|
|
}
|
2017-05-23 18:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
initView();
|
2016-07-06 00:19:09 +00:00
|
|
|
}]);
|