2019-03-21 05:46:49 +00:00
|
|
|
import _ from 'lodash-es';
|
|
|
|
|
2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2017-01-31 23:26:29 +00:00
|
|
|
.factory('InfoHelper', [function InfoHelperFactory() {
|
|
|
|
'use strict';
|
2018-04-04 00:31:04 +00:00
|
|
|
|
|
|
|
var helper = {};
|
|
|
|
|
2018-05-06 07:15:57 +00:00
|
|
|
helper.determineEndpointMode = function(info, type) {
|
2018-04-04 00:31:04 +00:00
|
|
|
var mode = {
|
|
|
|
provider: '',
|
2018-05-06 07:15:57 +00:00
|
|
|
role: '',
|
|
|
|
agentProxy: false
|
2018-04-04 00:31:04 +00:00
|
|
|
};
|
|
|
|
|
2018-05-06 07:15:57 +00:00
|
|
|
if (type === 2) {
|
|
|
|
mode.agentProxy = true;
|
|
|
|
}
|
|
|
|
|
2018-04-04 00:31:04 +00:00
|
|
|
if (!info.Swarm || _.isEmpty(info.Swarm.NodeID)) {
|
|
|
|
if (info.ID === 'vSphere Integrated Containers') {
|
|
|
|
mode.provider = 'VMWARE_VIC';
|
2017-01-31 23:26:29 +00:00
|
|
|
} else {
|
2018-04-04 00:31:04 +00:00
|
|
|
mode.provider = 'DOCKER_STANDALONE';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mode.provider = 'DOCKER_SWARM_MODE';
|
|
|
|
if (info.Swarm.ControlAvailable) {
|
|
|
|
mode.role = 'MANAGER';
|
|
|
|
} else {
|
|
|
|
mode.role = 'WORKER';
|
2017-01-31 23:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-04 00:31:04 +00:00
|
|
|
return mode;
|
2017-01-31 23:26:29 +00:00
|
|
|
};
|
2018-04-04 00:31:04 +00:00
|
|
|
|
|
|
|
return helper;
|
2017-01-31 23:26:29 +00:00
|
|
|
}]);
|