-
Notifications
You must be signed in to change notification settings - Fork 902
/
serverGroup.transformer.js
41 lines (31 loc) · 1.34 KB
/
serverGroup.transformer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
let angular = require('angular');
module.exports = angular.module('spinnaker.core.serverGroup.transformer', [
require('../cloudProvider/serviceDelegate.service.js'),
])
.factory('serverGroupTransformer', function (serviceDelegate) {
function normalizeServerGroup(serverGroup, application) {
return serviceDelegate.getDelegate(serverGroup.provider || serverGroup.type, 'serverGroup.transformer').
normalizeServerGroup(serverGroup, application);
}
function convertServerGroupCommandToDeployConfiguration(base) {
var service = serviceDelegate.getDelegate(base.selectedProvider, 'serverGroup.transformer');
return service ? service.convertServerGroupCommandToDeployConfiguration(base) : null;
}
// strips out Angular bits (see angular.js#toJsonReplacer), as well as executions and running tasks
function jsonReplacer(key, value) {
var val = value;
if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') {
val = undefined;
}
if (key === 'executions' || key === 'runningTasks') {
val = undefined;
}
return val;
}
return {
normalizeServerGroup: normalizeServerGroup,
convertServerGroupCommandToDeployConfiguration: convertServerGroupCommandToDeployConfiguration,
jsonReplacer: jsonReplacer,
};
});