mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
feat(volume-creation): add plugin support (#1044)
* feat(volume-creation): add plugin support * feat(plugins): only use systemInfo to retrieve plugins when API version < 1.25 * refactor(createVolume): remove unused dependencies
This commit is contained in:
parent
3919ad3ccf
commit
b08d2b07bc
5 changed files with 84 additions and 8 deletions
56
app/services/docker/pluginService.js
Normal file
56
app/services/docker/pluginService.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
angular.module('portainer.services')
|
||||
.factory('PluginService', ['$q', 'Plugin', 'SystemService', function PluginServiceFactory($q, Plugin, SystemService) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
|
||||
service.plugins = function() {
|
||||
var deferred = $q.defer();
|
||||
|
||||
Plugin.query({}).$promise
|
||||
.then(function success(data) {
|
||||
var plugins = data.map(function (item) {
|
||||
return new PluginViewModel(item);
|
||||
});
|
||||
deferred.resolve(plugins);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve plugins', err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.volumePlugins = function(systemOnly) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
$q.all({
|
||||
system: SystemService.plugins(),
|
||||
plugins: systemOnly ? [] : service.plugins()
|
||||
})
|
||||
.then(function success(data) {
|
||||
var volumePlugins = [];
|
||||
var systemPlugins = data.system;
|
||||
var plugins = data.plugins;
|
||||
|
||||
if (systemPlugins.Volume) {
|
||||
volumePlugins = volumePlugins.concat(systemPlugins.Volume);
|
||||
}
|
||||
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var plugin = plugins[i];
|
||||
if (plugin.Enabled && _.includes(plugin.Config.Interface.Types, 'docker.volumedriver/1.0')) {
|
||||
volumePlugins.push(plugin.Name);
|
||||
}
|
||||
}
|
||||
|
||||
deferred.resolve(volumePlugins);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: err.msg, err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
return service;
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue