UNPKG

@spotinst/spinnaker-deck

Version:

Spinnaker-Deck service, forked with support to Spotinst

62 lines (55 loc) 2.35 kB
import { IQService, module } from 'angular'; import { Application } from 'core/application/application.model'; import { INFRASTRUCTURE_KEY } from 'core/application/nav/defaultCategories'; import { CLUSTER_SERVICE, ClusterService } from 'core/cluster/cluster.service'; import { IServerGroup } from 'core/domain'; import { addManagedResourceMetadataToServerGroups } from 'core/managed'; import { JsonUtils } from 'core/utils'; import { ApplicationDataSourceRegistry } from '../application/service/ApplicationDataSourceRegistry'; import { EntityTagsReader } from '../entityTag/EntityTagsReader'; export const SERVER_GROUP_DATA_SOURCE = 'spinnaker.core.serverGroup.dataSource'; module(SERVER_GROUP_DATA_SOURCE, [CLUSTER_SERVICE]).run([ '$q', 'clusterService', ($q: IQService, clusterService: ClusterService) => { const loadServerGroups = (application: Application) => { return clusterService.loadServerGroups(application); }; const addServerGroups = (application: Application, serverGroups: IServerGroup[]) => { serverGroups.forEach( (serverGroup) => (serverGroup.stringVal = JsonUtils.makeSortedStringFromAngularObject(serverGroup, [ 'executions', 'runningTasks', ])), ); application.clusters = clusterService.createServerGroupClusters(serverGroups); const data = clusterService.addServerGroupsToApplication(application, serverGroups); clusterService.addTasksToServerGroups(application); clusterService.addExecutionsToServerGroups(application); return $q.when(data); }; const addTags = (application: Application) => { EntityTagsReader.addTagsToServerGroups(application); addManagedResourceMetadataToServerGroups(application); }; ApplicationDataSourceRegistry.registerDataSource({ key: 'serverGroups', label: 'Clusters', category: INFRASTRUCTURE_KEY, sref: '.insight.clusters', optional: true, primary: true, icon: 'fas fa-xs fa-fw fa-th-large', iconName: 'spMenuClusters', loader: loadServerGroups, onLoad: addServerGroups, afterLoad: addTags, providerField: 'type', credentialsField: 'account', regionField: 'region', description: 'Collections of server groups or jobs', defaultData: [], }); }, ]);