mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
feat(container-creation): add the ability to override the logging driver (#2384)
This commit is contained in:
parent
07c1e1bc3e
commit
7e6c647e93
2 changed files with 91 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
angular.module('portainer.docker')
|
||||
.controller('CreateContainerController', ['$q', '$scope', '$state', '$timeout', '$transition$', '$filter', 'Container', 'ContainerHelper', 'Image', 'ImageHelper', 'Volume', 'NetworkService', 'ResourceControlService', 'Authentication', 'Notifications', 'ContainerService', 'ImageService', 'FormValidator', 'ModalService', 'RegistryService', 'SystemService', 'SettingsService', 'HttpRequestHelper',
|
||||
function ($q, $scope, $state, $timeout, $transition$, $filter, Container, ContainerHelper, Image, ImageHelper, Volume, NetworkService, ResourceControlService, Authentication, Notifications, ContainerService, ImageService, FormValidator, ModalService, RegistryService, SystemService, SettingsService, HttpRequestHelper) {
|
||||
.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) {
|
||||
|
||||
$scope.create = create;
|
||||
|
||||
|
@ -19,7 +19,9 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai
|
|||
MemoryLimit: 0,
|
||||
MemoryReservation: 0,
|
||||
NodeName: null,
|
||||
capabilities: []
|
||||
capabilities: [],
|
||||
LogDriverName: '',
|
||||
LogDriverOpts: []
|
||||
};
|
||||
|
||||
$scope.extraNetworks = {};
|
||||
|
@ -110,6 +112,14 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai
|
|||
$scope.config.HostConfig.Devices.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.addLogDriverOpt = function() {
|
||||
$scope.formValues.LogDriverOpts.push({ name: '', value: ''});
|
||||
};
|
||||
|
||||
$scope.removeLogDriverOpt = function(index) {
|
||||
$scope.formValues.LogDriverOpts.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.fromContainerMultipleNetworks = false;
|
||||
|
||||
function prepareImageConfig(config) {
|
||||
|
@ -257,6 +267,23 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;});
|
||||
|
@ -278,6 +305,7 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai
|
|||
prepareLabels(config);
|
||||
prepareDevices(config);
|
||||
prepareResources(config);
|
||||
prepareLogDriver(config);
|
||||
prepareCapabilities(config);
|
||||
return config;
|
||||
}
|
||||
|
@ -568,6 +596,11 @@ function ($q, $scope, $state, $timeout, $transition$, $filter, Container, Contai
|
|||
Notifications.error('Failure', err, 'Unable to retrieve application settings');
|
||||
});
|
||||
|
||||
PluginService.loggingPlugins(apiVersion < 1.25)
|
||||
.then(function success(loggingDrivers) {
|
||||
$scope.availableLoggingDrivers = loggingDrivers;
|
||||
});
|
||||
|
||||
var userDetails = Authentication.getUserDetails();
|
||||
$scope.isAdmin = userDetails.role === 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue