diff --git a/app/scripts/modules/amazon/src/aws.module.ts b/app/scripts/modules/amazon/src/aws.module.ts index 71690f9e941..cad6f730b4d 100644 --- a/app/scripts/modules/amazon/src/aws.module.ts +++ b/app/scripts/modules/amazon/src/aws.module.ts @@ -6,7 +6,7 @@ import { AWS_LOAD_BALANCER_MODULE } from './loadBalancer/loadBalancer.module'; import { AWS_REACT_MODULE } from './reactShims/aws.react.module'; import { AWS_SECURITY_GROUP_MODULE } from './securityGroup/securityGroup.module'; import { AWS_SERVER_GROUP_TRANSFORMER } from './serverGroup/serverGroup.transformer'; -import { AMAZON_APPLICATION_NAME_VALIDATOR } from './validation/applicationName.validator'; +import './validation/ApplicationNameValidator'; import { VPC_MODULE } from './vpc/vpc.module'; import { SUBNET_RENDERER } from './subnet/subnet.renderer'; import { SERVER_GROUP_DETAILS_MODULE } from './serverGroup/details/serverGroupDetails.module'; @@ -49,7 +49,6 @@ templates.keys().forEach(function(key) { export const AMAZON_MODULE = 'spinnaker.amazon'; module(AMAZON_MODULE, [ AWS_REACT_MODULE, - AMAZON_APPLICATION_NAME_VALIDATOR, require('./pipeline/stages/bake/awsBakeStage').name, require('./pipeline/stages/cloneServerGroup/awsCloneServerGroupStage').name, require('./pipeline/stages/destroyAsg/awsDestroyAsgStage').name, diff --git a/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js b/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js index a1ddb36d4e9..75af3101afe 100644 --- a/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/amazon/src/instance/details/instance.details.controller.js @@ -6,7 +6,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, + InstanceReader, RecentHistoryService, SETTINGS, FirewallLabels, @@ -19,7 +19,6 @@ module.exports = angular require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), AMAZON_INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, require('../../vpc/vpcTag.directive.js').name, CONFIRMATION_MODAL_SERVICE, ]) @@ -29,7 +28,6 @@ module.exports = angular $uibModal, amazonInstanceWriter, confirmationModalService, - instanceReader, instance, app, moniker, @@ -176,7 +174,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { if ($scope.$$destroyed) { return; } diff --git a/app/scripts/modules/amazon/src/instance/details/instance.details.controller.spec.js b/app/scripts/modules/amazon/src/instance/details/instance.details.controller.spec.js index 0fe6a3c74c2..e6868cf2a55 100644 --- a/app/scripts/modules/amazon/src/instance/details/instance.details.controller.spec.js +++ b/app/scripts/modules/amazon/src/instance/details/instance.details.controller.spec.js @@ -1,18 +1,16 @@ -import { APPLICATION_MODEL_BUILDER } from '@spinnaker/core'; +import { APPLICATION_MODEL_BUILDER, InstanceReader } from '@spinnaker/core'; describe('Controller: awsInstanceDetailsCtrl', function() { var controller; var scope; - var instanceReader; var $q; var application; beforeEach(window.module(require('./instance.details.controller').name, APPLICATION_MODEL_BUILDER)); beforeEach( - window.inject(function($rootScope, $controller, _instanceReader_, _$q_, applicationModelBuilder) { + window.inject(function($rootScope, $controller, _$q_, applicationModelBuilder) { scope = $rootScope.$new(); - instanceReader = _instanceReader_; $q = _$q_; this.createController = function(application, instance) { @@ -45,7 +43,7 @@ describe('Controller: awsInstanceDetailsCtrl', function() { account: 'test', }; - spyOn(instanceReader, 'getInstanceDetails').and.returnValue($q.when(details)); + spyOn(InstanceReader, 'getInstanceDetails').and.returnValue($q.when(details)); application.loadBalancers.loaded = true; @@ -82,7 +80,7 @@ describe('Controller: awsInstanceDetailsCtrl', function() { account: 'test', }; - spyOn(instanceReader, 'getInstanceDetails').and.returnValue( + spyOn(InstanceReader, 'getInstanceDetails').and.returnValue( $q.when({ plain: function() { return details; diff --git a/app/scripts/modules/amazon/src/validation/applicationName.validator.ts b/app/scripts/modules/amazon/src/validation/ApplicationNameValidator.ts similarity index 80% rename from app/scripts/modules/amazon/src/validation/applicationName.validator.ts rename to app/scripts/modules/amazon/src/validation/ApplicationNameValidator.ts index bfd69c4bef6..5320f80f22e 100644 --- a/app/scripts/modules/amazon/src/validation/applicationName.validator.ts +++ b/app/scripts/modules/amazon/src/validation/ApplicationNameValidator.ts @@ -1,11 +1,4 @@ -import { module } from 'angular'; - -import { - APPLICATION_NAME_VALIDATOR, - FirewallLabels, - IApplicationNameValidator, - ApplicationNameValidator, -} from '@spinnaker/core'; +import { ApplicationNameValidator, FirewallLabels, IApplicationNameValidator } from '@spinnaker/core'; import { AWSProviderSettings } from '../aws.settings'; class AmazonApplicationNameValidator implements IApplicationNameValidator { @@ -20,8 +13,8 @@ class AmazonApplicationNameValidator implements IApplicationNameValidator { const lockoutDate = AWSProviderSettings.classicLaunchLockout; if (lockoutDate && lockoutDate < new Date().getTime()) { warnings.push( - `New applications deployed to AWS are restricted to VPC; you cannot create server groups, ' + - 'load balancers, or ${FirewallLabels.get('firewalls')} in EC2 Classic.`, + `New applications deployed to AWS are restricted to VPC; you cannot create server groups, + load balancers, or ${FirewallLabels.get('firewalls')} in EC2 Classic.`, ); } } @@ -86,11 +79,4 @@ class AmazonApplicationNameValidator implements IApplicationNameValidator { }; } } - -export const AMAZON_APPLICATION_NAME_VALIDATOR = 'spinnaker.amazon.validation.application.name'; - -module(AMAZON_APPLICATION_NAME_VALIDATOR, [APPLICATION_NAME_VALIDATOR]) - .service('awsApplicationNameValidator', AmazonApplicationNameValidator) - .run((applicationNameValidator: ApplicationNameValidator, awsApplicationNameValidator: IApplicationNameValidator) => { - applicationNameValidator.registerValidator('aws', awsApplicationNameValidator); - }); +ApplicationNameValidator.registerValidator('aws', new AmazonApplicationNameValidator()); diff --git a/app/scripts/modules/appengine/src/appengine.module.ts b/app/scripts/modules/appengine/src/appengine.module.ts index 4fc8d5d5c94..6fcf514ba63 100644 --- a/app/scripts/modules/appengine/src/appengine.module.ts +++ b/app/scripts/modules/appengine/src/appengine.module.ts @@ -16,7 +16,7 @@ import { APPENGINE_CLONE_SERVER_GROUP_CTRL } from './serverGroup/configure/wizar import { APPENGINE_SERVER_GROUP_DETAILS_CTRL } from './serverGroup/details/details.controller'; import { APPENGINE_SERVER_GROUP_TRANSFORMER } from './serverGroup/transformer'; import { APPENGINE_SERVER_GROUP_WRITER } from './serverGroup/writer/serverGroup.write.service'; -import { APPENGINE_APPLICATION_NAME_VALIDATOR } from './validation/applicationName.validator'; +import './validation/ApplicationNameValidator'; import './logo/appengine.logo.less'; @@ -28,7 +28,6 @@ templates.keys().forEach(function(key) { export const APPENGINE_MODULE = 'spinnaker.appengine'; module(APPENGINE_MODULE, [ - APPENGINE_APPLICATION_NAME_VALIDATOR, APPENGINE_CACHE_CONFIGURER, APPENGINE_CLONE_SERVER_GROUP_CTRL, APPENGINE_COMPONENT_URL_DETAILS, diff --git a/app/scripts/modules/appengine/src/instance/details/details.controller.ts b/app/scripts/modules/appengine/src/instance/details/details.controller.ts index 71b3e512959..4b2b2a19ec8 100644 --- a/app/scripts/modules/appengine/src/instance/details/details.controller.ts +++ b/app/scripts/modules/appengine/src/instance/details/details.controller.ts @@ -5,7 +5,6 @@ import { Application, CONFIRMATION_MODAL_SERVICE, ConfirmationModalService, - INSTANCE_READ_SERVICE, INSTANCE_WRITE_SERVICE, InstanceReader, InstanceWriter, @@ -37,7 +36,6 @@ class AppengineInstanceDetailsController implements IController { constructor( private $q: IQService, private app: Application, - private instanceReader: InstanceReader, private instanceWriter: InstanceWriter, private confirmationModalService: ConfirmationModalService, instance: InstanceFromStateParams, @@ -109,13 +107,15 @@ class AppengineInstanceDetailsController implements IController { } RecentHistoryService.addExtraDataToLatest('instances', recentHistoryExtraData); - return this.instanceReader - .getInstanceDetails(instanceManager.account, instanceManager.region, instance.instanceId) - .then((instanceDetails: IAppengineInstance) => { - instanceDetails.account = instanceManager.account; - instanceDetails.region = instanceManager.region; - return instanceDetails; - }); + return InstanceReader.getInstanceDetails( + instanceManager.account, + instanceManager.region, + instance.instanceId, + ).then((instanceDetails: IAppengineInstance) => { + instanceDetails.account = instanceManager.account; + instanceDetails.region = instanceManager.region; + return instanceDetails; + }); } else { return this.$q.reject(); } @@ -124,8 +124,7 @@ class AppengineInstanceDetailsController implements IController { export const APPENGINE_INSTANCE_DETAILS_CTRL = 'spinnaker.appengine.instanceDetails.controller'; -module(APPENGINE_INSTANCE_DETAILS_CTRL, [ - INSTANCE_READ_SERVICE, - INSTANCE_WRITE_SERVICE, - CONFIRMATION_MODAL_SERVICE, -]).controller('appengineInstanceDetailsCtrl', AppengineInstanceDetailsController); +module(APPENGINE_INSTANCE_DETAILS_CTRL, [INSTANCE_WRITE_SERVICE, CONFIRMATION_MODAL_SERVICE]).controller( + 'appengineInstanceDetailsCtrl', + AppengineInstanceDetailsController, +); diff --git a/app/scripts/modules/appengine/src/serverGroup/configure/serverGroupCommandBuilder.service.ts b/app/scripts/modules/appengine/src/serverGroup/configure/serverGroupCommandBuilder.service.ts index 2d9af240b32..3fbfa086908 100644 --- a/app/scripts/modules/appengine/src/serverGroup/configure/serverGroupCommandBuilder.service.ts +++ b/app/scripts/modules/appengine/src/serverGroup/configure/serverGroupCommandBuilder.service.ts @@ -2,8 +2,7 @@ import { IPromise, IQService, module } from 'angular'; import { AccountService, - STORAGE_ACCOUNT_SERVICE, - StorageAccountService, + StorageAccountReader, Application, IBuildTrigger, IExpectedArtifact, @@ -90,7 +89,7 @@ export class AppengineServerGroupCommandBuilder { return pipeline.expectedArtifacts || []; } - constructor(private $q: IQService, private storageAccountService: StorageAccountService) { + constructor(private $q: IQService) { 'ngInject'; } @@ -101,7 +100,7 @@ export class AppengineServerGroupCommandBuilder { ): IPromise { const dataToFetch = { accounts: AccountService.getAllAccountDetailsForProvider('appengine'), - storageAccounts: this.storageAccountService.getStorageAccounts(), + storageAccounts: StorageAccountReader.getStorageAccounts(), }; const viewState: IViewState = { @@ -207,7 +206,7 @@ export class AppengineServerGroupCommandBuilder { export const APPENGINE_SERVER_GROUP_COMMAND_BUILDER = 'spinnaker.appengine.serverGroupCommandBuilder.service'; -module(APPENGINE_SERVER_GROUP_COMMAND_BUILDER, [STORAGE_ACCOUNT_SERVICE]).service( +module(APPENGINE_SERVER_GROUP_COMMAND_BUILDER, []).service( 'appengineServerGroupCommandBuilder', AppengineServerGroupCommandBuilder, ); diff --git a/app/scripts/modules/appengine/src/validation/applicationName.validator.ts b/app/scripts/modules/appengine/src/validation/ApplicationNameValidator.ts similarity index 65% rename from app/scripts/modules/appengine/src/validation/applicationName.validator.ts rename to app/scripts/modules/appengine/src/validation/ApplicationNameValidator.ts index fdd2e5f88aa..a230a8c08ee 100644 --- a/app/scripts/modules/appengine/src/validation/applicationName.validator.ts +++ b/app/scripts/modules/appengine/src/validation/ApplicationNameValidator.ts @@ -1,11 +1,4 @@ -import { module } from 'angular'; - -import { - APPLICATION_NAME_VALIDATOR, - ApplicationNameValidator, - IApplicationNameValidator, - IValidationResult, -} from '@spinnaker/core'; +import { ApplicationNameValidator, IApplicationNameValidator, IValidationResult } from '@spinnaker/core'; // See https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions#Version class AppengineApplicationNameValidator implements IApplicationNameValidator { @@ -43,14 +36,4 @@ class AppengineApplicationNameValidator implements IApplicationNameValidator { } } -export const APPENGINE_APPLICATION_NAME_VALIDATOR = 'spinnaker.appengine.applicationNameValidator.service'; -module(APPENGINE_APPLICATION_NAME_VALIDATOR, [APPLICATION_NAME_VALIDATOR]) - .service('appengineApplicationNameValidator', AppengineApplicationNameValidator) - .run( - ( - applicationNameValidator: ApplicationNameValidator, - appengineApplicationNameValidator: IApplicationNameValidator, - ) => { - applicationNameValidator.registerValidator('appengine', appengineApplicationNameValidator); - }, - ); +ApplicationNameValidator.registerValidator('appengine', new AppengineApplicationNameValidator()); diff --git a/app/scripts/modules/azure/instance/details/instance.details.controller.js b/app/scripts/modules/azure/instance/details/instance.details.controller.js index a2613be011a..7a303af7077 100644 --- a/app/scripts/modules/azure/instance/details/instance.details.controller.js +++ b/app/scripts/modules/azure/instance/details/instance.details.controller.js @@ -6,7 +6,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, InstanceTemplates, RecentHistoryService, @@ -17,7 +17,6 @@ module.exports = angular require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, ]) .controller('azureInstanceDetailsCtrl', function( @@ -26,7 +25,6 @@ module.exports = angular $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, $q, @@ -128,7 +126,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then( + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then( function(details) { $scope.state.loading = false; extractHealthMetrics(instanceSummary, details); diff --git a/app/scripts/modules/azure/instance/details/instance.details.controller.spec.js b/app/scripts/modules/azure/instance/details/instance.details.controller.spec.js index 041b3907e06..895ba3dcecf 100644 --- a/app/scripts/modules/azure/instance/details/instance.details.controller.spec.js +++ b/app/scripts/modules/azure/instance/details/instance.details.controller.spec.js @@ -1,18 +1,16 @@ -import { APPLICATION_MODEL_BUILDER } from '@spinnaker/core'; +import { APPLICATION_MODEL_BUILDER, InstanceReader } from '@spinnaker/core'; describe('Controller: azureInstanceDetailsCtrl', function() { var controller; var scope; - var instanceReader; var $q; var application; beforeEach(window.module(require('./instance.details.controller').name, APPLICATION_MODEL_BUILDER)); beforeEach( - window.inject(function($rootScope, $controller, _instanceReader_, _$q_, applicationModelBuilder) { + window.inject(function($rootScope, $controller, _$q_, applicationModelBuilder) { scope = $rootScope.$new(); - instanceReader = _instanceReader_; $q = _$q_; application = applicationModelBuilder.createApplication( @@ -42,7 +40,7 @@ describe('Controller: azureInstanceDetailsCtrl', function() { account: 'test', }; - spyOn(instanceReader, 'getInstanceDetails').and.returnValue($q.when(details)); + spyOn(InstanceReader, 'getInstanceDetails').and.returnValue($q.when(details)); application.loadBalancers.loaded = true; @@ -79,7 +77,7 @@ describe('Controller: azureInstanceDetailsCtrl', function() { account: 'test', }; - spyOn(instanceReader, 'getInstanceDetails').and.returnValue( + spyOn(InstanceReader, 'getInstanceDetails').and.returnValue( $q.when({ plain: function() { return details; diff --git a/app/scripts/modules/cloudfoundry/instance/details/instance.details.controller.js b/app/scripts/modules/cloudfoundry/instance/details/instance.details.controller.js index 14ceeda16cc..7b596788176 100644 --- a/app/scripts/modules/cloudfoundry/instance/details/instance.details.controller.js +++ b/app/scripts/modules/cloudfoundry/instance/details/instance.details.controller.js @@ -6,7 +6,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, } from '@spinnaker/core'; @@ -16,7 +16,6 @@ module.exports = angular require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, ]) .controller('cfInstanceDetailsCtrl', function( @@ -26,7 +25,6 @@ module.exports = angular $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, moniker, @@ -132,7 +130,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { $scope.state.loading = false; extractHealthMetrics(instanceSummary, details); $scope.instance = _.defaults(details, instanceSummary); diff --git a/app/scripts/modules/core/src/application/config/appConfig.dataSource.js b/app/scripts/modules/core/src/application/config/appConfig.dataSource.js index 5af412983d9..c92745cff5f 100644 --- a/app/scripts/modules/core/src/application/config/appConfig.dataSource.js +++ b/app/scripts/modules/core/src/application/config/appConfig.dataSource.js @@ -3,7 +3,7 @@ import { APP_CONFIG_STATES } from './appConfig.states'; const angular = require('angular'); -module.exports = angular.module('spinnaker.core.application.config.dataSource', [APP_CONFIG_STATES]).run(function($q) { +module.exports = angular.module('spinnaker.core.application.config.dataSource', [APP_CONFIG_STATES]).run(function() { ApplicationDataSourceRegistry.registerDataSource({ key: 'config', label: 'Config', diff --git a/app/scripts/modules/core/src/application/index.ts b/app/scripts/modules/core/src/application/index.ts index 975299b7f8f..fecefcee5b8 100644 --- a/app/scripts/modules/core/src/application/index.ts +++ b/app/scripts/modules/core/src/application/index.ts @@ -2,7 +2,7 @@ export * from './ApplicationIcon'; export * from './application.model'; export * from './applicationModel.builder'; export * from './nav/defaultCategories'; -export * from './modal/validation/applicationName.validator'; +export * from './modal/validation/ApplicationNameValidator'; export * from './listExtractor/listExtractor.service'; export * from './service/ApplicationReader'; export * from './service/ApplicationWriter'; diff --git a/app/scripts/modules/core/src/application/modal/validation/applicationName.validator.spec.ts b/app/scripts/modules/core/src/application/modal/validation/ApplicationNameValidator.spec.ts similarity index 58% rename from app/scripts/modules/core/src/application/modal/validation/applicationName.validator.spec.ts rename to app/scripts/modules/core/src/application/modal/validation/ApplicationNameValidator.spec.ts index 8944f5ce121..6041085840b 100644 --- a/app/scripts/modules/core/src/application/modal/validation/applicationName.validator.spec.ts +++ b/app/scripts/modules/core/src/application/modal/validation/ApplicationNameValidator.spec.ts @@ -1,47 +1,25 @@ import { mock } from 'angular'; -import { - ApplicationNameValidator, - IApplicationNameValidationResult, - APPLICATION_NAME_VALIDATOR, -} from './applicationName.validator'; -import { - ExampleApplicationNameValidator, - ExampleApplicationNameValidator2, - EXAMPLE_APPLICATION_NAME_VALIDATOR, -} from './exampleApplicationName.validator'; +import { ApplicationNameValidator, IApplicationNameValidationResult } from './ApplicationNameValidator'; +import { ExampleApplicationNameValidator, ExampleApplicationNameValidator2 } from './ExampleApplicationNameValidator'; import { AccountService } from 'core/account/AccountService'; describe('Validator: applicationName', () => { - let validator: ApplicationNameValidator, - validator1: ExampleApplicationNameValidator, - validator2: ExampleApplicationNameValidator2, - $scope: ng.IScope; - - beforeEach(mock.module(APPLICATION_NAME_VALIDATOR, EXAMPLE_APPLICATION_NAME_VALIDATOR)); + const validator1 = new ExampleApplicationNameValidator(); + const validator2 = new ExampleApplicationNameValidator2(); + let $scope: ng.IScope; beforeEach( - mock.inject( - ( - applicationNameValidator: ApplicationNameValidator, - exampleApplicationNameValidator: ExampleApplicationNameValidator, - exampleApplicationNameValidator2: ExampleApplicationNameValidator2, - $rootScope: ng.IRootScopeService, - $q: ng.IQService, - ) => { - validator = applicationNameValidator; - validator1 = exampleApplicationNameValidator; - validator2 = exampleApplicationNameValidator2; - $scope = $rootScope; - spyOn(AccountService, 'listProviders').and.returnValue($q.when([validator1.provider, validator2.provider])); - }, - ), + mock.inject(($rootScope: ng.IRootScopeService, $q: ng.IQService) => { + $scope = $rootScope; + spyOn(AccountService, 'listProviders').and.returnValue($q.when([validator1.provider, validator2.provider])); + }), ); describe('warning messages', () => { it('aggregates warning messages when multiple or no providers are specified', () => { let result: IApplicationNameValidationResult = null; - validator.validate(validator1.COMMON_WARNING_CONDITION, []).then(r => (result = r)); + ApplicationNameValidator.validate(validator1.COMMON_WARNING_CONDITION, []).then(r => (result = r)); $scope.$digest(); expect(result.warnings.length).toBe(2); expect(result.warnings[0].cloudProvider).toEqual(validator1.provider); @@ -49,9 +27,10 @@ describe('Validator: applicationName', () => { expect(result.warnings[1].cloudProvider).toEqual(validator2.provider); expect(result.warnings[1].message).toEqual(validator2.COMMON_WARNING_MESSAGE); - validator - .validate(validator1.COMMON_WARNING_CONDITION, [validator1.provider, validator2.provider]) - .then(r => (result = r)); + ApplicationNameValidator.validate(validator1.COMMON_WARNING_CONDITION, [ + validator1.provider, + validator2.provider, + ]).then(r => (result = r)); $scope.$digest(); expect(result.warnings[0].message).toEqual(validator1.COMMON_WARNING_MESSAGE); expect(result.warnings[0].cloudProvider).toEqual(validator1.provider); @@ -61,11 +40,11 @@ describe('Validator: applicationName', () => { it('provides warnings only from provider when specified', () => { let result: IApplicationNameValidationResult = null; - validator.validate(validator1.WARNING_CONDITION, [validator2.provider]).then(r => (result = r)); + ApplicationNameValidator.validate(validator1.WARNING_CONDITION, [validator2.provider]).then(r => (result = r)); $scope.$digest(); expect(result.warnings.length).toBe(0); - validator.validate(validator1.WARNING_CONDITION, [validator1.provider]).then(r => (result = r)); + ApplicationNameValidator.validate(validator1.WARNING_CONDITION, [validator1.provider]).then(r => (result = r)); $scope.$digest(); expect(result.warnings.length).toBe(1); expect(result.warnings[0].cloudProvider).toEqual(validator1.provider); @@ -76,7 +55,7 @@ describe('Validator: applicationName', () => { describe('error messages', () => { it('aggregates error messages when multiple or no providers are specified', () => { let result: IApplicationNameValidationResult = null; - validator.validate(validator1.COMMON_ERROR_CONDITION, []).then(r => (result = r)); + ApplicationNameValidator.validate(validator1.COMMON_ERROR_CONDITION, []).then(r => (result = r)); $scope.$digest(); expect(result.errors.length).toBe(2); expect(result.errors[0].cloudProvider).toEqual(validator1.provider); @@ -84,9 +63,10 @@ describe('Validator: applicationName', () => { expect(result.errors[1].cloudProvider).toEqual(validator2.provider); expect(result.errors[1].message).toEqual(validator2.COMMON_ERROR_MESSAGE); - validator - .validate(validator1.COMMON_ERROR_CONDITION, [validator1.provider, validator2.provider]) - .then(r => (result = r)); + ApplicationNameValidator.validate(validator1.COMMON_ERROR_CONDITION, [ + validator1.provider, + validator2.provider, + ]).then(r => (result = r)); $scope.$digest(); expect(result.errors[0].message).toEqual(validator1.COMMON_ERROR_MESSAGE); expect(result.errors[0].cloudProvider).toEqual(validator1.provider); @@ -96,11 +76,11 @@ describe('Validator: applicationName', () => { it('provides errors only from provider when specified', () => { let result: IApplicationNameValidationResult = null; - validator.validate(validator1.ERROR_CONDITION, [validator2.provider]).then(r => (result = r)); + ApplicationNameValidator.validate(validator1.ERROR_CONDITION, [validator2.provider]).then(r => (result = r)); $scope.$digest(); expect(result.errors.length).toBe(0); - validator.validate(validator1.ERROR_CONDITION, [validator1.provider]).then(r => (result = r)); + ApplicationNameValidator.validate(validator1.ERROR_CONDITION, [validator1.provider]).then(r => (result = r)); $scope.$digest(); expect(result.errors.length).toBe(1); expect(result.errors[0].cloudProvider).toEqual(validator1.provider); diff --git a/app/scripts/modules/core/src/application/modal/validation/applicationName.validator.ts b/app/scripts/modules/core/src/application/modal/validation/ApplicationNameValidator.ts similarity index 71% rename from app/scripts/modules/core/src/application/modal/validation/applicationName.validator.ts rename to app/scripts/modules/core/src/application/modal/validation/ApplicationNameValidator.ts index 899c56cb923..a2645096f7c 100644 --- a/app/scripts/modules/core/src/application/modal/validation/applicationName.validator.ts +++ b/app/scripts/modules/core/src/application/modal/validation/ApplicationNameValidator.ts @@ -1,5 +1,4 @@ -import { module } from 'angular'; -import { CloudProviderRegistry } from 'core/cloudProvider'; +import { IPromise } from 'angular'; import { AccountService } from 'core/account/AccountService'; export interface IApplicationNameValidationMessage { @@ -26,20 +25,18 @@ export interface IApplicationNameValidator { * when creating a new application. */ export class ApplicationNameValidator { - private providerMap: Map = new Map(); + private static providerMap: Map = new Map(); /** * Registers a validator for a cloud provider. * @param cloudProvider the key of the cloud provider, e.g. "aws", "gce" * @param validator the actual validator */ - public registerValidator(cloudProvider: string, validator: IApplicationNameValidator) { - if (CloudProviderRegistry.getProvider(cloudProvider)) { - if (!this.providerMap.has(cloudProvider)) { - this.providerMap.set(cloudProvider, []); - } - this.providerMap.get(cloudProvider).push(validator); + public static registerValidator(cloudProvider: string, validator: IApplicationNameValidator) { + if (!this.providerMap.has(cloudProvider)) { + this.providerMap.set(cloudProvider, []); } + this.providerMap.get(cloudProvider).push(validator); } /** @@ -49,13 +46,15 @@ export class ApplicationNameValidator { * @param providersToTest the configured cloud providers; if empty, validators for all providers will fire * @returns {{errors: Array, warnings: Array}} */ - public validate(applicationName: string, providersToTest: string[]): ng.IPromise { + public static validate( + applicationName: string, + providersToTest: string[], + ): IPromise { return AccountService.listProviders().then((availableProviders: string[]) => { const toCheck = providersToTest && providersToTest.length ? providersToTest : availableProviders; const errors: IApplicationNameValidationMessage[] = [], warnings: IApplicationNameValidationMessage[] = []; - toCheck.forEach((provider: string) => { if (this.providerMap.has(provider)) { this.providerMap.get(provider).forEach(validator => { @@ -69,7 +68,3 @@ export class ApplicationNameValidator { }); } } - -export const APPLICATION_NAME_VALIDATOR = 'spinnaker.core.application.name.validator'; - -module(APPLICATION_NAME_VALIDATOR, []).service('applicationNameValidator', ApplicationNameValidator); diff --git a/app/scripts/modules/core/src/application/modal/validation/exampleApplicationName.validator.ts b/app/scripts/modules/core/src/application/modal/validation/ExampleApplicationNameValidator.ts similarity index 66% rename from app/scripts/modules/core/src/application/modal/validation/exampleApplicationName.validator.ts rename to app/scripts/modules/core/src/application/modal/validation/ExampleApplicationNameValidator.ts index 1ed9ba91d97..4a28b91f40f 100644 --- a/app/scripts/modules/core/src/application/modal/validation/exampleApplicationName.validator.ts +++ b/app/scripts/modules/core/src/application/modal/validation/ExampleApplicationNameValidator.ts @@ -1,10 +1,4 @@ -import { module } from 'angular'; -import { - APPLICATION_NAME_VALIDATOR, - IApplicationNameValidator, - ApplicationNameValidator, - IValidationResult, -} from './applicationName.validator'; +import { ApplicationNameValidator, IApplicationNameValidator, IValidationResult } from './ApplicationNameValidator'; import { CloudProviderRegistry } from 'core/cloudProvider'; import { SETTINGS } from 'core/config/settings'; @@ -114,24 +108,11 @@ export class ExampleApplicationNameValidator2 implements IApplicationNameValidat } } -export const EXAMPLE_APPLICATION_NAME_VALIDATOR = 'spinnaker.core.application.modal.validation.example.applicationName'; +ApplicationNameValidator.registerValidator('example', new ExampleApplicationNameValidator()); +ApplicationNameValidator.registerValidator('example2', new ExampleApplicationNameValidator2()); -module(EXAMPLE_APPLICATION_NAME_VALIDATOR, [APPLICATION_NAME_VALIDATOR]) - .service('exampleApplicationNameValidator', ExampleApplicationNameValidator) - .service('exampleApplicationNameValidator2', ExampleApplicationNameValidator2) - .run( - ( - applicationNameValidator: ApplicationNameValidator, - exampleApplicationNameValidator: ExampleApplicationNameValidator, - exampleApplicationNameValidator2: ExampleApplicationNameValidator2, - ) => { - applicationNameValidator.registerValidator('example', exampleApplicationNameValidator); - applicationNameValidator.registerValidator('example2', exampleApplicationNameValidator2); - }, - ) - .config(() => { - SETTINGS.providers.example = { defaults: { account: 'test' }, resetToOriginal: () => {} }; - SETTINGS.providers.example2 = { defaults: { account: 'test' }, resetToOriginal: () => {} }; - CloudProviderRegistry.registerProvider('example', { name: 'example' }); - CloudProviderRegistry.registerProvider('example2', { name: 'example2' }); - }); +CloudProviderRegistry.registerProvider('example', { name: 'example' }); +CloudProviderRegistry.registerProvider('example2', { name: 'example2' }); + +SETTINGS.providers.example = { defaults: { account: 'test' }, resetToOriginal: () => {} }; +SETTINGS.providers.example2 = { defaults: { account: 'test' }, resetToOriginal: () => {} }; diff --git a/app/scripts/modules/core/src/application/modal/validation/applicationNameValidationMessages.component.ts b/app/scripts/modules/core/src/application/modal/validation/applicationNameValidationMessages.component.ts index cb10b639565..9342425e801 100644 --- a/app/scripts/modules/core/src/application/modal/validation/applicationNameValidationMessages.component.ts +++ b/app/scripts/modules/core/src/application/modal/validation/applicationNameValidationMessages.component.ts @@ -1,9 +1,5 @@ import { IController, module } from 'angular'; -import { - APPLICATION_NAME_VALIDATOR, - ApplicationNameValidator, - IApplicationNameValidationResult, -} from 'core/application/modal/validation/applicationName.validator'; +import { ApplicationNameValidator, IApplicationNameValidationResult } from './ApplicationNameValidator'; /** * This directive is responsible for rendering error and warning messages to the screen when creating a new application. @@ -14,12 +10,8 @@ class ApplicationNameValidationMessagesController implements IController { public cloudProviders: string[]; public messages: IApplicationNameValidationResult; - public constructor(private applicationNameValidator: ApplicationNameValidator) { - 'ngInject'; - } - public $onChanges(): void { - this.applicationNameValidator.validate(this.name, this.cloudProviders).then(r => (this.messages = r)); + ApplicationNameValidator.validate(this.name, this.cloudProviders).then(r => (this.messages = r)); } } @@ -47,7 +39,7 @@ class ApplicationNameValidationMessagesComponent implements ng.IComponentOptions export const APPLICATION_NAME_VALIDATION_MESSAGES = 'spinnaker.core.application.applicationNameValidationMessages'; -module(APPLICATION_NAME_VALIDATION_MESSAGES, [APPLICATION_NAME_VALIDATOR]).component( +module(APPLICATION_NAME_VALIDATION_MESSAGES, []).component( 'applicationNameValidationMessages', new ApplicationNameValidationMessagesComponent(), ); diff --git a/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.spec.ts b/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.spec.ts index 1fbe1d1d687..f3360c0ce43 100644 --- a/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.spec.ts +++ b/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.spec.ts @@ -1,30 +1,20 @@ -import { mock } from 'angular'; +import { ICompileService, IQService, IRootScopeService, mock } from 'angular'; -import { - EXAMPLE_APPLICATION_NAME_VALIDATOR, - ExampleApplicationNameValidator, - ExampleApplicationNameValidator2, -} from './exampleApplicationName.validator'; +import { ExampleApplicationNameValidator, ExampleApplicationNameValidator2 } from './ExampleApplicationNameValidator'; import { VALIDATE_APPLICATION_NAME } from './validateApplicationName.directive'; import { AccountService } from 'core/account/AccountService'; describe('Validator: validateApplicationName', function() { - let validator1: ExampleApplicationNameValidator, validator2: ExampleApplicationNameValidator2, $q: ng.IQService; + const validator1 = new ExampleApplicationNameValidator(); + const validator2 = new ExampleApplicationNameValidator2(); + let $q: IQService; - beforeEach(mock.module(EXAMPLE_APPLICATION_NAME_VALIDATOR, VALIDATE_APPLICATION_NAME)); + beforeEach(mock.module(VALIDATE_APPLICATION_NAME)); beforeEach( - mock.inject(function( - $rootScope: ng.IRootScopeService, - $compile: ng.ICompileService, - exampleApplicationNameValidator: ExampleApplicationNameValidator, - exampleApplicationNameValidator2: ExampleApplicationNameValidator2, - _$q_: ng.IQService, - ) { + mock.inject(function($rootScope: IRootScopeService, $compile: ICompileService, _$q_: IQService) { this.$rootScope = $rootScope; this.compile = $compile; - validator1 = exampleApplicationNameValidator; - validator2 = exampleApplicationNameValidator2; $q = _$q_; }), ); diff --git a/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.ts b/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.ts index 27d373f3eea..790631ce7d2 100644 --- a/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.ts +++ b/app/scripts/modules/core/src/application/modal/validation/validateApplicationName.directive.ts @@ -1,9 +1,5 @@ import { IAttributes, IController, IDeferred, INgModelController, IQService, IScope, module } from 'angular'; -import { - APPLICATION_NAME_VALIDATOR, - ApplicationNameValidator, - IApplicationNameValidationResult, -} from 'core/application/modal/validation/applicationName.validator'; +import { ApplicationNameValidator, IApplicationNameValidationResult } from './ApplicationNameValidator'; interface IValidateNameAttrs extends IAttributes { cloudProviders: string; @@ -21,20 +17,18 @@ class ValidateApplicationNameController implements IController { public $attrs: IValidateNameAttrs; public $scope: IScope; - public constructor(private applicationNameValidator: ApplicationNameValidator, private $q: IQService) {} + constructor(private $q: IQService) {} public initialize() { this.model.$asyncValidators['validateApplicationName'] = (value: string) => { const deferred: IDeferred = this.$q.defer(); - this.applicationNameValidator - .validate(value, this.cloudProviders) - .then((result: IApplicationNameValidationResult) => { - if (result.errors.length) { - deferred.reject(); - } else { - deferred.resolve(); - } - }); + ApplicationNameValidator.validate(value, this.cloudProviders).then((result: IApplicationNameValidationResult) => { + if (result.errors.length) { + deferred.reject(); + } else { + deferred.resolve(); + } + }); return deferred.promise; }; this.$scope.$watch(this.$attrs.cloudProviders, () => this.model.$validate()); @@ -43,7 +37,7 @@ class ValidateApplicationNameController implements IController { export const VALIDATE_APPLICATION_NAME = 'spinnaker.core.application.modal.validateApplicationName.component'; -module(VALIDATE_APPLICATION_NAME, [APPLICATION_NAME_VALIDATOR]).directive('validateApplicationName', function() { +module(VALIDATE_APPLICATION_NAME, []).directive('validateApplicationName', function() { return { restrict: 'A', controller: ValidateApplicationNameController, diff --git a/app/scripts/modules/core/src/core.module.ts b/app/scripts/modules/core/src/core.module.ts index 1c6cd6dcf4b..be17c751cf2 100644 --- a/app/scripts/modules/core/src/core.module.ts +++ b/app/scripts/modules/core/src/core.module.ts @@ -45,7 +45,6 @@ import { HELP_MODULE } from './help/help.module'; import { INSIGHT_NGMODULE } from './insight/insight.module'; import { INTERCEPTOR_MODULE } from './interceptor/interceptor.module'; import { LOAD_BALANCER_MODULE } from './loadBalancer/loadBalancer.module'; -import { MANIFEST_MODULE } from 'core/manifest/manifestWriter.module'; import { NETWORK_INTERCEPTOR } from './api/network.interceptor'; @@ -118,8 +117,6 @@ module(CORE_MODULE, [ LOAD_BALANCER_MODULE, - MANIFEST_MODULE, - require('./modal/modal.module').name, NETWORK_INTERCEPTOR, diff --git a/app/scripts/modules/core/src/entityTag/entityTags.read.service.ts b/app/scripts/modules/core/src/entityTag/EntityTagsReader.ts similarity index 81% rename from app/scripts/modules/core/src/entityTag/entityTags.read.service.ts rename to app/scripts/modules/core/src/entityTag/EntityTagsReader.ts index ae6f5afc2c1..6eb38154ab6 100644 --- a/app/scripts/modules/core/src/entityTag/entityTags.read.service.ts +++ b/app/scripts/modules/core/src/entityTag/EntityTagsReader.ts @@ -1,4 +1,6 @@ -import { module, IQService, IPromise } from 'angular'; +import { IPromise } from 'angular'; + +import { $q } from 'ngimport'; import { API } from 'core/api/ApiService'; import { IEntityTags, IEntityTag, ICreationMetadataTag } from '../domain/IEntityTags'; @@ -7,18 +9,14 @@ import { IServerGroup, ILoadBalancer, ISecurityGroup } from 'core/domain'; import { SETTINGS } from 'core/config/settings'; export class EntityTagsReader { - constructor(private $q: IQService) { - 'ngInject'; - } - - public getAllEntityTagsForApplication(application: string): IPromise { + public static getAllEntityTagsForApplication(application: string): IPromise { return API.one('tags') .withParams({ application }) .getList() .then((allTags: IEntityTags[]) => this.flattenTagsAndAddMetadata(allTags)); } - public addTagsToServerGroups(application: Application): void { + public static addTagsToServerGroups(application: Application): void { if (!SETTINGS.feature.entityTags) { return; } @@ -41,7 +39,7 @@ export class EntityTagsReader { }); } - public addTagsToLoadBalancers(application: Application): void { + public static addTagsToLoadBalancers(application: Application): void { if (!SETTINGS.feature.entityTags) { return; } @@ -57,7 +55,7 @@ export class EntityTagsReader { }); } - public addTagsToSecurityGroups(application: Application): void { + public static addTagsToSecurityGroups(application: Application): void { if (!SETTINGS.feature.entityTags) { return; } @@ -73,9 +71,9 @@ export class EntityTagsReader { }); } - public getEntityTagsForId(entityType: string, entityId: string): IPromise { + public static getEntityTagsForId(entityType: string, entityId: string): IPromise { if (!entityId) { - return this.$q.when([]); + return $q.when([]); } return API.one('tags') .withParams({ @@ -87,11 +85,11 @@ export class EntityTagsReader { return this.flattenTagsAndAddMetadata(entityTagGroups); }) .catch(() => { - return this.$q.when([]); + return $q.when([]); }); } - private flattenTagsAndAddMetadata(entityTags: IEntityTags[]): IEntityTags[] { + private static flattenTagsAndAddMetadata(entityTags: IEntityTags[]): IEntityTags[] { const allTags: IEntityTags[] = []; entityTags.forEach(entityTag => { entityTag.tags.forEach(tag => this.addTagMetadata(entityTag, tag)); @@ -103,7 +101,7 @@ export class EntityTagsReader { return allTags; } - private addTagMetadata(entityTag: IEntityTags, tag: IEntityTag): void { + private static addTagMetadata(entityTag: IEntityTags, tag: IEntityTag): void { const metadata = entityTag.tagsMetadata.find(m => m.name === tag.name); if (metadata) { tag.created = metadata.created; @@ -113,6 +111,3 @@ export class EntityTagsReader { } } } - -export const ENTITY_TAGS_READ_SERVICE = 'spinnaker.core.entityTag.read.service'; -module(ENTITY_TAGS_READ_SERVICE, []).service('entityTagsReader', EntityTagsReader); diff --git a/app/scripts/modules/core/src/entityTag/entityTags.dataSource.ts b/app/scripts/modules/core/src/entityTag/entityTags.dataSource.ts index 022c9afbd49..4b018cfbea5 100644 --- a/app/scripts/modules/core/src/entityTag/entityTags.dataSource.ts +++ b/app/scripts/modules/core/src/entityTag/entityTags.dataSource.ts @@ -2,47 +2,45 @@ import { module, IQService } from 'angular'; import { ApplicationDataSourceRegistry } from 'core/application/service/ApplicationDataSourceRegistry'; import { Application } from 'core/application/application.model'; -import { ENTITY_TAGS_READ_SERVICE, EntityTagsReader } from './entityTags.read.service'; +import { EntityTagsReader } from './EntityTagsReader'; import { IEntityTags } from 'core/domain/IEntityTags'; import { noop } from 'core/utils'; import { LOAD_BALANCER_READ_SERVICE } from 'core/loadBalancer/loadBalancer.read.service'; import { SETTINGS } from 'core/config/settings'; export const ENTITY_TAGS_DATA_SOURCE = 'spinnaker.core.entityTag.dataSource'; -module(ENTITY_TAGS_DATA_SOURCE, [ENTITY_TAGS_READ_SERVICE, LOAD_BALANCER_READ_SERVICE]).run( - ($q: IQService, entityTagsReader: EntityTagsReader) => { - if (!SETTINGS.feature.entityTags) { - return; - } - const loadEntityTags = (application: Application) => { - return entityTagsReader.getAllEntityTagsForApplication(application.name); - }; +module(ENTITY_TAGS_DATA_SOURCE, [LOAD_BALANCER_READ_SERVICE]).run(($q: IQService) => { + if (!SETTINGS.feature.entityTags) { + return; + } + const loadEntityTags = (application: Application) => { + return EntityTagsReader.getAllEntityTagsForApplication(application.name); + }; - const addEntityTags = (_application: Application, data: IEntityTags[]) => { - return $q.when(data); - }; + const addEntityTags = (_application: Application, data: IEntityTags[]) => { + return $q.when(data); + }; - const addTagsToEntities = (application: Application) => { - application - .getDataSource('serverGroups') - .ready() - .then(() => entityTagsReader.addTagsToServerGroups(application), noop); - application - .getDataSource('loadBalancers') - .ready() - .then(() => entityTagsReader.addTagsToLoadBalancers(application), noop); - application - .getDataSource('securityGroups') - .ready() - .then(() => entityTagsReader.addTagsToSecurityGroups(application), noop); - }; + const addTagsToEntities = (application: Application) => { + application + .getDataSource('serverGroups') + .ready() + .then(() => EntityTagsReader.addTagsToServerGroups(application), noop); + application + .getDataSource('loadBalancers') + .ready() + .then(() => EntityTagsReader.addTagsToLoadBalancers(application), noop); + application + .getDataSource('securityGroups') + .ready() + .then(() => EntityTagsReader.addTagsToSecurityGroups(application), noop); + }; - ApplicationDataSourceRegistry.registerDataSource({ - key: 'entityTags', - visible: false, - loader: loadEntityTags, - onLoad: addEntityTags, - afterLoad: addTagsToEntities, - }); - }, -); + ApplicationDataSourceRegistry.registerDataSource({ + key: 'entityTags', + visible: false, + loader: loadEntityTags, + onLoad: addEntityTags, + afterLoad: addTagsToEntities, + }); +}); diff --git a/app/scripts/modules/core/src/entityTag/index.ts b/app/scripts/modules/core/src/entityTag/index.ts index d8dbca15d80..516798f08e8 100644 --- a/app/scripts/modules/core/src/entityTag/index.ts +++ b/app/scripts/modules/core/src/entityTag/index.ts @@ -1,6 +1,6 @@ export * from './AddEntityTagLinks'; export * from './EntityTagEditor'; export * from './clusterTargetBuilder'; -export * from './entityTags.read.service'; +export * from './EntityTagsReader'; export * from './entityTags.write.service'; export * from './notifications'; diff --git a/app/scripts/modules/core/src/instance/instance.read.service.ts b/app/scripts/modules/core/src/instance/InstanceReader.ts similarity index 59% rename from app/scripts/modules/core/src/instance/instance.read.service.ts rename to app/scripts/modules/core/src/instance/InstanceReader.ts index 20c52e779b3..8a3f01ae5a3 100644 --- a/app/scripts/modules/core/src/instance/instance.read.service.ts +++ b/app/scripts/modules/core/src/instance/InstanceReader.ts @@ -1,4 +1,4 @@ -import { module } from 'angular'; +import { IPromise } from 'angular'; import { API } from 'core/api/ApiService'; import { IInstance } from 'core/domain'; @@ -7,7 +7,7 @@ export interface IInstanceConsoleOutput { } export class InstanceReader { - public getInstanceDetails(account: string, region: string, id: string): ng.IPromise { + public static getInstanceDetails(account: string, region: string, id: string): IPromise { return API.one('instances') .one(account) .one(region) @@ -15,12 +15,12 @@ export class InstanceReader { .get(); } - public getConsoleOutput( + public static getConsoleOutput( account: string, region: string, id: string, cloudProvider: string, - ): ng.IPromise { + ): IPromise { return API.one('instances') .all(account) .all(region) @@ -29,6 +29,3 @@ export class InstanceReader { .get(); } } - -export const INSTANCE_READ_SERVICE = 'spinnaker.core.instance.read.service'; -module(INSTANCE_READ_SERVICE, []).service('instanceReader', InstanceReader); diff --git a/app/scripts/modules/core/src/instance/details/console/consoleOutput.modal.controller.js b/app/scripts/modules/core/src/instance/details/console/consoleOutput.modal.controller.js index 4f7626b5dd8..2106ec58ede 100644 --- a/app/scripts/modules/core/src/instance/details/console/consoleOutput.modal.controller.js +++ b/app/scripts/modules/core/src/instance/details/console/consoleOutput.modal.controller.js @@ -1,19 +1,19 @@ 'use strict'; -import { INSTANCE_READ_SERVICE } from 'core/instance/instance.read.service'; +import { InstanceReader } from 'core/instance/InstanceReader'; const angular = require('angular'); module.exports = angular - .module('spinnaker.core.instance.details.console.controller', [INSTANCE_READ_SERVICE]) - .controller('ConsoleOutputCtrl', function($scope, $uibModalInstance, instanceReader, instance) { + .module('spinnaker.core.instance.details.console.controller', []) + .controller('ConsoleOutputCtrl', function($scope, $uibModalInstance, instance) { const instanceId = instance.instanceId || instance.id; $scope.vm = { loading: true, instanceId: instanceId, }; - instanceReader.getConsoleOutput(instance.account, instance.region, instanceId, instance.provider).then( + InstanceReader.getConsoleOutput(instance.account, instance.region, instanceId, instance.provider).then( function(response) { $scope.vm.consoleOutput = response.output; $scope.vm.loading = false; diff --git a/app/scripts/modules/core/src/instance/index.ts b/app/scripts/modules/core/src/instance/index.ts index 315a8ffd3a1..3160e56d1f0 100644 --- a/app/scripts/modules/core/src/instance/index.ts +++ b/app/scripts/modules/core/src/instance/index.ts @@ -1,4 +1,4 @@ -export * from './instance.read.service'; +export * from './InstanceReader'; export * from './instance.write.service'; export * from './instanceType.service'; export * from './templates'; diff --git a/app/scripts/modules/core/src/loadBalancer/loadBalancer.dataSource.ts b/app/scripts/modules/core/src/loadBalancer/loadBalancer.dataSource.ts index bcbd8bad4e3..37ce7c0696c 100644 --- a/app/scripts/modules/core/src/loadBalancer/loadBalancer.dataSource.ts +++ b/app/scripts/modules/core/src/loadBalancer/loadBalancer.dataSource.ts @@ -3,13 +3,13 @@ import { module, IQService } from 'angular'; import { ApplicationDataSourceRegistry } from 'core/application/service/ApplicationDataSourceRegistry'; import { INFRASTRUCTURE_KEY } from 'core/application/nav/defaultCategories'; import { Application } from 'core/application/application.model'; -import { ENTITY_TAGS_READ_SERVICE, EntityTagsReader } from 'core/entityTag/entityTags.read.service'; +import { EntityTagsReader } from 'core/entityTag/EntityTagsReader'; import { ILoadBalancer } from 'core/domain'; import { LOAD_BALANCER_READ_SERVICE, LoadBalancerReader } from 'core/loadBalancer/loadBalancer.read.service'; export const LOAD_BALANCER_DATA_SOURCE = 'spinnaker.core.loadBalancer.dataSource'; -module(LOAD_BALANCER_DATA_SOURCE, [ENTITY_TAGS_READ_SERVICE, LOAD_BALANCER_READ_SERVICE]).run( - ($q: IQService, loadBalancerReader: LoadBalancerReader, entityTagsReader: EntityTagsReader) => { +module(LOAD_BALANCER_DATA_SOURCE, [LOAD_BALANCER_READ_SERVICE]).run( + ($q: IQService, loadBalancerReader: LoadBalancerReader) => { const loadLoadBalancers = (application: Application) => { return loadBalancerReader.loadLoadBalancers(application.name); }; @@ -19,7 +19,7 @@ module(LOAD_BALANCER_DATA_SOURCE, [ENTITY_TAGS_READ_SERVICE, LOAD_BALANCER_READ_ }; const addTags = (application: Application) => { - entityTagsReader.addTagsToLoadBalancers(application); + EntityTagsReader.addTagsToLoadBalancers(application); }; ApplicationDataSourceRegistry.registerDataSource({ diff --git a/app/scripts/modules/core/src/manifest/manifestReader.service.ts b/app/scripts/modules/core/src/manifest/ManifestReader.ts similarity index 100% rename from app/scripts/modules/core/src/manifest/manifestReader.service.ts rename to app/scripts/modules/core/src/manifest/ManifestReader.ts diff --git a/app/scripts/modules/core/src/manifest/manifestWriter.service.ts b/app/scripts/modules/core/src/manifest/ManifestWriter.ts similarity index 69% rename from app/scripts/modules/core/src/manifest/manifestWriter.service.ts rename to app/scripts/modules/core/src/manifest/ManifestWriter.ts index 4f61de3fbe5..5a7168553f9 100644 --- a/app/scripts/modules/core/src/manifest/manifestWriter.service.ts +++ b/app/scripts/modules/core/src/manifest/ManifestWriter.ts @@ -1,11 +1,11 @@ -import { IPromise, module } from 'angular'; +import { IPromise } from 'angular'; import { Application } from 'core/application/application.model'; import { ITask } from 'core/domain'; import { TaskExecutor } from 'core/task/taskExecutor'; export class ManifestWriter { - public deployManifest(command: any, application: Application): IPromise { + public static deployManifest(command: any, application: Application): IPromise { const description = 'Deploy manifest'; command.type = 'deployManifest'; return TaskExecutor.executeTask({ @@ -15,7 +15,7 @@ export class ManifestWriter { }); } - public deleteManifest(command: any, application: Application): IPromise { + public static deleteManifest(command: any, application: Application): IPromise { const description = 'Delete manifest'; command.type = 'deleteManifest'; return TaskExecutor.executeTask({ @@ -25,7 +25,7 @@ export class ManifestWriter { }); } - public scaleManifest(command: any, application: Application): IPromise { + public static scaleManifest(command: any, application: Application): IPromise { const description = 'Scale manifest'; command.type = 'scaleManifest'; return TaskExecutor.executeTask({ @@ -35,7 +35,7 @@ export class ManifestWriter { }); } - public undoRolloutManifest(command: any, application: Application): IPromise { + public static undoRolloutManifest(command: any, application: Application): IPromise { const description = 'Undo rollout of manifest'; command.type = 'undoRolloutManifest'; return TaskExecutor.executeTask({ @@ -45,7 +45,7 @@ export class ManifestWriter { }); } - public resumeRolloutManifest(command: any, application: Application): IPromise { + public static resumeRolloutManifest(command: any, application: Application): IPromise { const description = 'Resume rollout of manifest'; command.type = 'resumeRolloutManifest'; return TaskExecutor.executeTask({ @@ -55,7 +55,7 @@ export class ManifestWriter { }); } - public pauseRolloutManifest(command: any, application: Application): IPromise { + public static pauseRolloutManifest(command: any, application: Application): IPromise { const description = 'Pause rollout of manifest'; command.type = 'pauseRolloutManifest'; return TaskExecutor.executeTask({ @@ -65,7 +65,7 @@ export class ManifestWriter { }); } - public findArtifactsFromResource(command: any, application: Application): IPromise { + public static findArtifactsFromResource(command: any, application: Application): IPromise { const description = 'Find artifacts from a Kubernetes resource'; command.type = 'findArtifactsFromResource'; return TaskExecutor.executeTask({ @@ -75,6 +75,3 @@ export class ManifestWriter { }); } } - -export const MANIFEST_WRITER = 'spinnaker.core.manifest.write.service'; -module(MANIFEST_WRITER, []).service('manifestWriter', ManifestWriter); diff --git a/app/scripts/modules/core/src/manifest/index.ts b/app/scripts/modules/core/src/manifest/index.ts index 7c8b48f6b9b..b96b2397d1e 100644 --- a/app/scripts/modules/core/src/manifest/index.ts +++ b/app/scripts/modules/core/src/manifest/index.ts @@ -1,2 +1,2 @@ -export * from './manifestWriter.service'; -export * from './manifestReader.service'; +export * from './ManifestWriter'; +export * from './ManifestReader'; diff --git a/app/scripts/modules/core/src/manifest/manifestWriter.module.ts b/app/scripts/modules/core/src/manifest/manifestWriter.module.ts deleted file mode 100644 index 00abf3d0eba..00000000000 --- a/app/scripts/modules/core/src/manifest/manifestWriter.module.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { module } from 'angular'; -import { MANIFEST_WRITER } from 'core/manifest/manifestWriter.service'; - -export const MANIFEST_MODULE = 'spinnaker.core.manifest'; -module(MANIFEST_MODULE, [MANIFEST_WRITER]); diff --git a/app/scripts/modules/core/src/pipeline/config/pipelineConfigurer.js b/app/scripts/modules/core/src/pipeline/config/pipelineConfigurer.js index bde9372db65..f04b9f38527 100644 --- a/app/scripts/modules/core/src/pipeline/config/pipelineConfigurer.js +++ b/app/scripts/modules/core/src/pipeline/config/pipelineConfigurer.js @@ -11,6 +11,7 @@ import { EditPipelineJsonModalCtrl } from './actions/json/editPipelineJsonModal. import { PipelineConfigValidator } from './validation/PipelineConfigValidator'; import { EXECUTION_BUILD_TITLE } from '../executionBuild/ExecutionBuildTitle'; import { PipelineConfigService } from 'core/pipeline/config/services/PipelineConfigService'; +import { ExecutionsTransformer } from 'core/pipeline/service/ExecutionsTransformer'; module.exports = angular .module('spinnaker.core.pipeline.config.pipelineConfigurer', [OVERRIDE_REGISTRY, EXECUTION_BUILD_TITLE]) @@ -36,7 +37,6 @@ module.exports = angular $window, $q, executionService, - executionsTransformer, overrideRegistry, $location, ) { @@ -425,7 +425,7 @@ module.exports = angular application: $scope.pipeline.application, }) .then(executions => { - executions.forEach(execution => executionsTransformer.addBuildInfo(execution)); + executions.forEach(execution => ExecutionsTransformer.addBuildInfo(execution)); $scope.pipelineExecutions = executions; if ($scope.plan && $scope.plan.executionId) { $scope.currentExecution = _.find($scope.pipelineExecutions, { id: $scope.plan.executionId }); diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/pipeline/PipelineTriggerTemplate.tsx b/app/scripts/modules/core/src/pipeline/config/triggers/pipeline/PipelineTriggerTemplate.tsx index bb4bb0ad34f..08f81e8ffc0 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/pipeline/PipelineTriggerTemplate.tsx +++ b/app/scripts/modules/core/src/pipeline/config/triggers/pipeline/PipelineTriggerTemplate.tsx @@ -11,6 +11,7 @@ import { Spinner } from 'core/widgets/spinners/Spinner'; import { ExecutionBuildTitle } from 'core/pipeline/executionBuild/ExecutionBuildTitle'; import { timestamp } from 'core/utils/timeFormatters'; import { TetheredSelect } from 'core/presentation/TetheredSelect'; +import { ExecutionsTransformer } from 'core/pipeline/service/ExecutionsTransformer'; export interface IPipelineTriggerTemplateState { executions: IExecution[]; @@ -91,7 +92,7 @@ export class PipelineTriggerTemplate extends React.Component< const trigger = this.props.command.trigger as IPipelineTrigger; if (executions.length) { - executions.forEach(execution => ReactInjector.executionsTransformer.addBuildInfo(execution)); + executions.forEach(execution => ExecutionsTransformer.addBuildInfo(execution)); // default to what is supplied by the trigger if possible; otherwise, use the latest const defaultSelection = executions.find(e => e.id === trigger.parentPipelineId) || executions[0]; newState.selectedExecution = defaultSelection.id; diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts index 954ed8bf26d..12ddde17e35 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts +++ b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts @@ -1,7 +1,7 @@ import { IController, module } from 'angular'; import { IPubsubSubscription, IPubsubTrigger } from 'core/domain'; -import { PUBSUB_SUBSCRIPTION_SERVICE, PubsubSubscriptionService } from 'core/pubsub'; +import { PubsubSubscriptionReader } from 'core/pubsub'; import { Registry } from 'core/registry'; import { ServiceAccountReader } from 'core/serviceAccount'; import { SETTINGS } from 'core/config/settings'; @@ -13,7 +13,7 @@ class PubsubTriggerController implements IController { public subscriptionsLoaded = false; public serviceAccounts: string[]; - constructor(public trigger: IPubsubTrigger, private pubsubSubscriptionService: PubsubSubscriptionService) { + constructor(public trigger: IPubsubTrigger) { 'ngInject'; this.subscriptionsLoaded = false; @@ -25,8 +25,7 @@ class PubsubTriggerController implements IController { // If we ever need a refresh button in pubsubTrigger.html, call this function. public refreshPubsubSubscriptions(): void { - this.pubsubSubscriptionService - .getPubsubSubscriptions() + PubsubSubscriptionReader.getPubsubSubscriptions() .then(subscriptions => (this.pubsubSubscriptions = subscriptions)) .catch(() => (this.pubsubSubscriptions = [])) .finally(() => { @@ -43,7 +42,7 @@ class PubsubTriggerController implements IController { } export const PUBSUB_TRIGGER = 'spinnaker.core.pipeline.trigger.pubsub'; -module(PUBSUB_TRIGGER, [PUBSUB_SUBSCRIPTION_SERVICE]) +module(PUBSUB_TRIGGER, []) .config(() => { Registry.pipeline.registerTrigger({ label: 'Pub/Sub', diff --git a/app/scripts/modules/core/src/pipeline/service/executions.transformer.service.spec.ts b/app/scripts/modules/core/src/pipeline/service/ExecutionsTransformer.spec.ts similarity index 88% rename from app/scripts/modules/core/src/pipeline/service/executions.transformer.service.spec.ts rename to app/scripts/modules/core/src/pipeline/service/ExecutionsTransformer.spec.ts index 126927e21cc..22e62b1d39f 100644 --- a/app/scripts/modules/core/src/pipeline/service/executions.transformer.service.spec.ts +++ b/app/scripts/modules/core/src/pipeline/service/ExecutionsTransformer.spec.ts @@ -1,20 +1,10 @@ -import { mock } from 'angular'; import { map } from 'lodash'; import { Application } from '../../application'; -import { EXECUTIONS_TRANSFORMER_SERVICE, ExecutionsTransformerService } from './executions.transformer.service'; +import { ExecutionsTransformer } from './ExecutionsTransformer'; import { IExecution } from '../../domain'; -describe('executionTransformerService', function() { - let transformer: ExecutionsTransformerService; - beforeEach(mock.module(EXECUTIONS_TRANSFORMER_SERVICE)); - - beforeEach( - mock.inject((executionsTransformer: ExecutionsTransformerService) => { - transformer = executionsTransformer; - }), - ); - +describe('ExecutionTransformerService', function() { describe('transformExecution', () => { it('should flatten stages into summaries', () => { const execution = { @@ -30,7 +20,7 @@ describe('executionTransformerService', function() { ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(map(execution.stageSummaries[0].stages, 'id')).toEqual(['e', 'f', 'b', 'c', 'a', 'g', 'd', 'h']); }); @@ -48,7 +38,7 @@ describe('executionTransformerService', function() { ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(map(execution.stageSummaries[0].stages, 'id')).toEqual(['c', 'f', 'e', 'b', 'a', 'g', 'd', 'h']); }); @@ -56,7 +46,7 @@ describe('executionTransformerService', function() { const execution = { stages: [{ id: '1', name: 'bake' }, { id: '2', name: 'deploy' }, { id: '3', name: 'wait' }], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries.length).toBe(3); expect(map(execution.stageSummaries, 'name')).toEqual(['bake', 'deploy', 'wait']); @@ -75,7 +65,7 @@ describe('executionTransformerService', function() { { id: '8', parentStageId: '3', syntheticStageOwner: 'STAGE_AFTER' }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries.length).toBe(3); expect(map(execution.stageSummaries[0].stages, 'id')).toEqual(['5', '1']); @@ -110,7 +100,7 @@ describe('executionTransformerService', function() { { id: '8', parentStageId: '3', syntheticStageOwner: 'STAGE_AFTER', status: 'NOT_STARTED' }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].status).toBe('SUCCEEDED'); expect(execution.stageSummaries[0].startTime).toBe(5); @@ -140,7 +130,7 @@ describe('executionTransformerService', function() { { id: '6', parentStageId: '2', syntheticStageOwner: 'STAGE_BEFORE', status: 'NOT_STARTED', startTime: 6 }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].status).toBe('CANCELED'); }); @@ -159,7 +149,7 @@ describe('executionTransformerService', function() { { id: '6', parentStageId: '2', syntheticStageOwner: 'STAGE_BEFORE', status: 'NOT_STARTED', startTime: 6 }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].status).toBe('NOT_STARTED'); }); @@ -178,7 +168,7 @@ describe('executionTransformerService', function() { { id: '6', parentStageId: '2', syntheticStageOwner: 'STAGE_BEFORE', status: 'RUNNING', startTime: 6 }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].endTime).toBeUndefined(); }); @@ -212,7 +202,7 @@ describe('executionTransformerService', function() { }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].endTime).toBe(11); }); @@ -240,7 +230,7 @@ describe('executionTransformerService', function() { { id: '5', parentStageId: '2', syntheticStageOwner: 'STAGE_AFTER', status: 'NOT_STARTED' }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); const summary = execution.stageSummaries[0]; @@ -291,7 +281,7 @@ describe('executionTransformerService', function() { }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].startTime).toBe(4); }); }); @@ -306,7 +296,7 @@ describe('executionTransformerService', function() { { id: '6', parentStageId: '2', syntheticStageOwner: 'STAGE_AFTER', status: 'RUNNING' }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].firstActiveStage).toBe(1); }); @@ -319,7 +309,7 @@ describe('executionTransformerService', function() { { id: '6', parentStageId: '2', syntheticStageOwner: 'STAGE_AFTER', status: 'SUCCEEDED' }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].firstActiveStage).toBe(0); }); @@ -332,7 +322,7 @@ describe('executionTransformerService', function() { { id: '6', parentStageId: '2', syntheticStageOwner: 'STAGE_AFTER', status: 'TERMINAL' }, ], } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.stageSummaries[0].firstActiveStage).toBe(2); }); }); @@ -354,19 +344,19 @@ describe('executionTransformerService', function() { it('adds buildInfo from deployment details', () => { const execution = { stages: [deployStage] } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo).toEqual({ number: 3, url: 'http://jenkinshost/job/jobName/3' }); }); it('adds buildInfo from lastBuild if present', () => { const execution = { stages: [], trigger: { buildInfo: { lastBuild } } } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo.number).toBe(4); }); it('adds buildInfo from trigger', () => { const execution = { stages: [], trigger: { buildInfo: triggerBuild } } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo.number).toBe(6); }); @@ -375,7 +365,7 @@ describe('executionTransformerService', function() { stages: [], trigger: { parentExecution: { trigger: { buildInfo: parentBuild } } }, } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo.number).toBe(5); }); @@ -383,7 +373,7 @@ describe('executionTransformerService', function() { const execution = { stages: [deployStage], trigger: { buildInfo: triggerBuild } } as IExecution; execution.trigger.buildInfo.lastBuild = lastBuild; execution.trigger.parentExecution = { trigger: { buildInfo: parentBuild } } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo).toEqual({ number: 3, url: 'http://jenkinshost/job/jobName/3' }); }); @@ -391,14 +381,14 @@ describe('executionTransformerService', function() { const execution = { stages: [], trigger: { buildInfo: triggerBuild } } as IExecution; execution.trigger.buildInfo.lastBuild = lastBuild; execution.trigger.parentExecution = { trigger: { buildInfo: parentBuild } } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo.number).toBe(4); }); it('prefers trigger details to parent execution', () => { const execution = { stages: [], trigger: { buildInfo: triggerBuild } } as IExecution; execution.trigger.parentExecution = { trigger: { buildInfo: parentBuild } } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo.number).toBe(6); }); @@ -415,7 +405,7 @@ describe('executionTransformerService', function() { }, }; const execution = { stages: [deployStage] } as IExecution; - transformer.transformExecution({} as Application, execution); + ExecutionsTransformer.transformExecution({} as Application, execution); expect(execution.buildInfo).toEqual({ number: 3, url: 'http://custom/url' }); }); }); diff --git a/app/scripts/modules/core/src/pipeline/service/executions.transformer.service.ts b/app/scripts/modules/core/src/pipeline/service/ExecutionsTransformer.ts similarity index 90% rename from app/scripts/modules/core/src/pipeline/service/executions.transformer.service.ts rename to app/scripts/modules/core/src/pipeline/service/ExecutionsTransformer.ts index c9ad108875e..824eb914d79 100644 --- a/app/scripts/modules/core/src/pipeline/service/executions.transformer.service.ts +++ b/app/scripts/modules/core/src/pipeline/service/ExecutionsTransformer.ts @@ -1,5 +1,3 @@ -import { module } from 'angular'; - import { duration } from 'moment'; import { find, findLast, flattenDeep, get, has, maxBy, uniq, sortBy } from 'lodash'; @@ -10,15 +8,15 @@ import { IExecution, IExecutionStage, IExecutionStageSummary, IOrchestratedItem import { OrchestratedItemTransformer } from 'core/orchestratedItem/orchestratedItem.transformer'; import { Registry } from 'core/registry'; -export class ExecutionsTransformerService { - private hiddenStageTypes = [ +export class ExecutionsTransformer { + private static hiddenStageTypes = [ 'initialization', 'pipelineInitialization', 'waitForRequisiteCompletion', 'determineTargetServerGroup', ]; - private addDeploymentTargets(execution: IExecution): void { + private static addDeploymentTargets(execution: IExecution): void { const targets: string[] = []; execution.stages.forEach(stage => { const stageConfig = Registry.pipeline.getStageConfig(stage); @@ -29,7 +27,7 @@ export class ExecutionsTransformerService { execution.deploymentTargets = uniq(flattenDeep(targets)).sort(); } - private siblingStageSorter(a: IOrchestratedItem, b: IOrchestratedItem): number { + private static siblingStageSorter(a: IOrchestratedItem, b: IOrchestratedItem): number { if (!a.startTime && !b.startTime) { return 0; } @@ -42,7 +40,10 @@ export class ExecutionsTransformerService { return a.startTime - b.startTime; } - private flattenStages(stages: IExecutionStage[], stage: IExecutionStage | IExecutionStageSummary): IExecutionStage[] { + private static flattenStages( + stages: IExecutionStage[], + stage: IExecutionStage | IExecutionStageSummary, + ): IExecutionStage[] { const stageSummary = stage as IExecutionStageSummary; if (stageSummary.groupStages) { stageSummary.groupStages.forEach(s => this.flattenStages(stages, s)); @@ -64,13 +65,13 @@ export class ExecutionsTransformerService { return stages; } - private flattenAndFilter(stage: IExecutionStage | IExecutionStageSummary): IExecutionStage[] { + private static flattenAndFilter(stage: IExecutionStage | IExecutionStageSummary): IExecutionStage[] { return this.flattenStages([], stage).filter( s => s.isFailed || (!this.hiddenStageTypes.includes(s.type) && s.initializationStage !== true), ); } - private getCurrentStages(execution: IExecution) { + private static getCurrentStages(execution: IExecution) { const currentStages = execution.stageSummaries.filter(stage => stage.isRunning); // if there are no running stages, find the first enqueued stage if (!currentStages.length) { @@ -83,14 +84,14 @@ export class ExecutionsTransformerService { } // TODO: remove if we ever figure out why quickPatchAsgStage never has a startTime - private setMasterStageStartTime(stages: IExecutionStage[], stage: IExecutionStageSummary): void { + private static setMasterStageStartTime(stages: IExecutionStage[], stage: IExecutionStageSummary): void { const allStartTimes = stages.filter(child => child.startTime).map(child => child.startTime); if (allStartTimes.length) { stage.startTime = Math.min(...allStartTimes); } } - private getCurrentStage(stages: T[]) { + private static getCurrentStage(stages: T[]) { const lastStage = stages[stages.length - 1]; const lastNotStartedStage = findLast(stages, childStage => childStage.hasNotStarted); const lastFailedStage = findLast(stages, childStage => childStage.isFailed); @@ -102,7 +103,7 @@ export class ExecutionsTransformerService { ); } - private cleanupLockStages(stages: IExecutionStage[]): IExecutionStage[] { + private static cleanupLockStages(stages: IExecutionStage[]): IExecutionStage[] { const retainFirstOfType = (type: string, toRetain: IExecutionStage[]) => { let foundType = false; return toRetain.filter(s => { @@ -119,7 +120,7 @@ export class ExecutionsTransformerService { return retainFirstOfType('releaseLock', retainFirstOfType('acquireLock', stages).reverse()).reverse(); } - private transformStage(stage: IExecutionStageSummary): void { + private static transformStage(stage: IExecutionStageSummary): void { const stages = this.cleanupLockStages(this.flattenAndFilter(stage)); if (!stages.length) { return; @@ -148,7 +149,7 @@ export class ExecutionsTransformerService { stage.stages = stages; } - private applyPhasesAndLink(execution: IExecution): void { + private static applyPhasesAndLink(execution: IExecution): void { const stages = execution.stages; let allPhasesResolved = true; // remove any invalid requisiteStageRefIds, set requisiteStageRefIds to empty for synthetic stages @@ -188,11 +189,11 @@ export class ExecutionsTransformerService { } } - private addStageWidths(execution: IExecution): void { + private static addStageWidths(execution: IExecution): void { execution.stageWidth = 100 / execution.stageSummaries.length + '%'; } - private styleStage(stage: IExecutionStageSummary, styleStage?: IExecutionStageSummary): void { + private static styleStage(stage: IExecutionStageSummary, styleStage?: IExecutionStageSummary): void { styleStage = styleStage || stage; const stageConfig = Registry.pipeline.getStageConfig(styleStage); if (stageConfig) { @@ -203,7 +204,7 @@ export class ExecutionsTransformerService { } } - private findNearestBuildInfo(execution: IExecution): any { + private static findNearestBuildInfo(execution: IExecution): any { if (has(execution, 'trigger.buildInfo.number')) { return execution.trigger.buildInfo; } @@ -213,7 +214,7 @@ export class ExecutionsTransformerService { return null; } - public addBuildInfo(execution: IExecution): void { + public static addBuildInfo(execution: IExecution): void { execution.buildInfo = this.findNearestBuildInfo(execution); if (has(execution, 'trigger.buildInfo.lastBuild.number')) { @@ -232,7 +233,7 @@ export class ExecutionsTransformerService { } } - private transformStageSummary(summary: IExecutionStageSummary, index: number): void { + private static transformStageSummary(summary: IExecutionStageSummary, index: number): void { summary.index = index; summary.stages = this.flattenAndFilter(summary); summary.stages.forEach(stage => delete stage.stages); @@ -251,20 +252,20 @@ export class ExecutionsTransformerService { } } - private filterStages(summary: IExecutionStageSummary): void { + private static filterStages(summary: IExecutionStageSummary): void { const stageConfig = Registry.pipeline.getStageConfig(summary.masterStage); if (stageConfig && stageConfig.stageFilter) { summary.stages = summary.stages.filter(s => stageConfig.stageFilter(s)); } } - private setExecutionWindow(summary: IExecutionStageSummary): void { + private static setExecutionWindow(summary: IExecutionStageSummary): void { if (summary.stages.some(s => s.type === 'restrictExecutionDuringTimeWindow' && s.isSuspended)) { summary.inSuspendedExecutionWindow = true; } } - private setFirstActiveStage(summary: IExecutionStageSummary): void { + private static setFirstActiveStage(summary: IExecutionStageSummary): void { summary.firstActiveStage = 0; const steps = summary.stages || []; if (steps.find(s => s.isRunning)) { @@ -275,7 +276,7 @@ export class ExecutionsTransformerService { } } - public transformExecution(application: Application, execution: IExecution): void { + public static transformExecution(application: Application, execution: IExecution): void { if (execution.trigger) { execution.isStrategy = execution.trigger.isPipeline === false && execution.trigger.type === 'pipeline'; } @@ -314,7 +315,7 @@ export class ExecutionsTransformerService { this.processStageSummaries(execution); } - private calculateRunningTime(stage: IExecutionStageSummary): () => number { + private static calculateRunningTime(stage: IExecutionStageSummary): () => number { return () => { // Find the earliest startTime and latest endTime stage.groupStages.forEach(subStage => { @@ -334,7 +335,7 @@ export class ExecutionsTransformerService { }; } - public processStageSummaries(execution: IExecution): void { + public static processStageSummaries(execution: IExecution): void { let stageSummaries: IExecutionStageSummary[] = []; execution.stages.forEach(stage => { if (!stage.syntheticStageOwner && !this.hiddenStageTypes.includes(stage.type)) { @@ -470,6 +471,3 @@ export class ExecutionsTransformerService { this.addDeploymentTargets(execution); } } - -export const EXECUTIONS_TRANSFORMER_SERVICE = 'spinnaker.core.pipeline.executionTransformer.service'; -module(EXECUTIONS_TRANSFORMER_SERVICE, []).service('executionsTransformer', ExecutionsTransformerService); diff --git a/app/scripts/modules/core/src/pipeline/service/execution.service.ts b/app/scripts/modules/core/src/pipeline/service/execution.service.ts index 4f151b93b7f..2f9ca477b5b 100644 --- a/app/scripts/modules/core/src/pipeline/service/execution.service.ts +++ b/app/scripts/modules/core/src/pipeline/service/execution.service.ts @@ -4,10 +4,7 @@ import { StateService } from '@uirouter/core'; import { API } from 'core/api/ApiService'; import { Application } from 'core/application/application.model'; -import { - EXECUTIONS_TRANSFORMER_SERVICE, - ExecutionsTransformerService, -} from 'core/pipeline/service/executions.transformer.service'; +import { ExecutionsTransformer } from 'core/pipeline/service/ExecutionsTransformer'; import { IExecution, IExecutionStage, IExecutionStageSummary } from 'core/domain'; import { Registry } from 'core/registry'; import { JsonUtils } from 'core/utils'; @@ -41,7 +38,6 @@ export class ExecutionService { private $q: IQService, private $state: StateService, private $timeout: ITimeoutService, - private executionsTransformer: ExecutionsTransformerService, ) { 'ngInject'; } @@ -113,7 +109,7 @@ export class ExecutionService { } public transformExecution(application: Application, execution: IExecution): void { - this.executionsTransformer.transformExecution(application, execution); + ExecutionsTransformer.transformExecution(application, execution); } public transformExecutions(application: Application, executions: IExecution[], currentData: IExecution[] = []): void { @@ -126,7 +122,7 @@ export class ExecutionService { const match = currentData.find((test: IExecution) => test.id === execution.id); if (!match || !match.stringVal || match.stringVal !== stringVal) { execution.stringVal = stringVal; - this.executionsTransformer.transformExecution(application, execution); + ExecutionsTransformer.transformExecution(application, execution); } }); } @@ -337,7 +333,7 @@ export class ExecutionService { if (!executions || !executions.length) { return []; } - executions.forEach(execution => this.executionsTransformer.transformExecution({} as Application, execution)); + executions.forEach(execution => ExecutionsTransformer.transformExecution({} as Application, execution)); return executions.sort((a, b) => b.startTime - (a.startTime || Date.now())); }); } @@ -573,10 +569,10 @@ export class ExecutionService { } export const EXECUTION_SERVICE = 'spinnaker.core.pipeline.executions.service'; -module(EXECUTION_SERVICE, [EXECUTIONS_TRANSFORMER_SERVICE]).factory( +module(EXECUTION_SERVICE, []).factory( 'executionService', - ($http: IHttpService, $q: IQService, $state: StateService, $timeout: ITimeoutService, executionsTransformer: any) => - new ExecutionService($http, $q, $state, $timeout, executionsTransformer), + ($http: IHttpService, $q: IQService, $state: StateService, $timeout: ITimeoutService) => + new ExecutionService($http, $q, $state, $timeout), ); DebugWindow.addInjectable('executionService'); diff --git a/app/scripts/modules/core/src/presentation/navigation/pageNavigationState.ts b/app/scripts/modules/core/src/presentation/navigation/PageNavigationState.ts similarity index 50% rename from app/scripts/modules/core/src/presentation/navigation/pageNavigationState.ts rename to app/scripts/modules/core/src/presentation/navigation/PageNavigationState.ts index 2123bda06ce..1d7c8a67424 100644 --- a/app/scripts/modules/core/src/presentation/navigation/pageNavigationState.ts +++ b/app/scripts/modules/core/src/presentation/navigation/PageNavigationState.ts @@ -1,5 +1,3 @@ -import { module } from 'angular'; - export interface INavigationPage { key: string; label: string; @@ -8,28 +6,24 @@ export interface INavigationPage { } export class PageNavigationState { - public currentPageKey: string; - public pages: INavigationPage[] = []; + public static currentPageKey: string; + public static pages: INavigationPage[] = []; - public reset(): void { + public static reset(): void { this.pages.length = 0; this.currentPageKey = null; } - public setCurrentPage(key: string) { + public static setCurrentPage(key: string) { if (this.pages.some(p => p.key === key)) { this.currentPageKey = key; } } - public registerPage(page: INavigationPage) { + public static registerPage(page: INavigationPage) { this.pages.push(page); if (!this.currentPageKey) { this.currentPageKey = page.key; } } } - -export const PAGE_NAVIGATION_STATE = 'spinnaker.core.presentation.navigation.pageState'; - -module(PAGE_NAVIGATION_STATE, []).service('pageNavigationState', PageNavigationState); diff --git a/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.spec.ts b/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.spec.ts index 561eb772988..abd93e8abec 100644 --- a/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.spec.ts +++ b/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.spec.ts @@ -2,7 +2,7 @@ import * as $ from 'jquery'; import { mock } from 'angular'; import { PAGE_NAVIGATOR_COMPONENT } from './pageNavigator.component'; -import { INavigationPage } from './pageNavigationState'; +import { INavigationPage } from './PageNavigationState'; import { ScrollToService } from '../../utils/scrollTo/scrollTo.service'; describe('Component: Page Navigator', () => { diff --git a/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.ts b/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.ts index f52b924dca4..f611fa4360d 100644 --- a/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.ts +++ b/app/scripts/modules/core/src/presentation/navigation/pageNavigator.component.ts @@ -1,5 +1,5 @@ import { IController, module } from 'angular'; -import { PageNavigationState, PAGE_NAVIGATION_STATE } from './pageNavigationState'; +import { PageNavigationState } from './PageNavigationState'; import { throttle } from 'lodash'; import { ScrollToService } from 'core/utils/scrollTo/scrollTo.service'; import { PAGE_SECTION_COMPONENT } from './pageSection.component'; @@ -8,6 +8,7 @@ import './pageNavigation.less'; class PageNavigatorController implements IController { public scrollableContainer: string; + public pageNavigationState: PageNavigationState = PageNavigationState; private container: JQuery; private navigator: JQuery; private id: string; @@ -16,13 +17,13 @@ class PageNavigatorController implements IController { return `scroll.pageNavigation.${this.id}`; } - public constructor(private $element: JQuery, public pageNavigationState: PageNavigationState) { + public constructor(private $element: JQuery) { 'ngInject'; } public $onInit(): void { this.id = UUIDGenerator.generateUuid(); - this.pageNavigationState.reset(); + PageNavigationState.reset(); this.container = this.$element.closest(this.scrollableContainer); this.container.bind(this.getEventKey(), throttle(() => this.handleScroll(), 20)); this.navigator = this.$element.find('.page-navigation'); @@ -33,7 +34,7 @@ class PageNavigatorController implements IController { } public setCurrentSection(key: string): void { - this.pageNavigationState.setCurrentPage(key); + PageNavigationState.setCurrentPage(key); ScrollToService.scrollTo(`[data-page-id=${key}]`, this.scrollableContainer, this.container.offset().top); this.container.find('.highlighted').removeClass('highlighted'); this.container.find(`[data-page-id=${key}]`).addClass('highlighted'); @@ -43,7 +44,7 @@ class PageNavigatorController implements IController { const navigatorRect = this.$element.get(0).getBoundingClientRect(), scrollableContainerTop = this.container.get(0).getBoundingClientRect().top; - const currentPage = this.pageNavigationState.pages.find(p => { + const currentPage = PageNavigationState.pages.find(p => { const content = this.container.find(`[data-page-content=${p.key}]`); if (content.length) { return content.get(0).getBoundingClientRect().bottom > scrollableContainerTop; @@ -51,7 +52,7 @@ class PageNavigatorController implements IController { return false; }); if (currentPage) { - this.pageNavigationState.setCurrentPage(currentPage.key); + PageNavigationState.setCurrentPage(currentPage.key); this.navigator.find('li').removeClass('current'); this.navigator.find(`[data-page-navigation-link=${currentPage.key}]`).addClass('current'); } @@ -102,7 +103,4 @@ class PageNavigatorComponent implements ng.IComponentOptions { export const PAGE_NAVIGATOR_COMPONENT = 'spinnaker.core.presentation.navigation.pageNavigator'; -module(PAGE_NAVIGATOR_COMPONENT, [PAGE_NAVIGATION_STATE, PAGE_SECTION_COMPONENT]).component( - 'pageNavigator', - new PageNavigatorComponent(), -); +module(PAGE_NAVIGATOR_COMPONENT, [PAGE_SECTION_COMPONENT]).component('pageNavigator', new PageNavigatorComponent()); diff --git a/app/scripts/modules/core/src/presentation/navigation/pageSection.component.ts b/app/scripts/modules/core/src/presentation/navigation/pageSection.component.ts index 818cfa26d91..5e94c2877de 100644 --- a/app/scripts/modules/core/src/presentation/navigation/pageSection.component.ts +++ b/app/scripts/modules/core/src/presentation/navigation/pageSection.component.ts @@ -1,10 +1,10 @@ -import { IController, module } from 'angular'; -import { PageNavigationState, INavigationPage } from './pageNavigationState'; +import { IChangesObject, IComponentOptions, IController, IOnChangesObject, module } from 'angular'; +import { PageNavigationState, INavigationPage } from './PageNavigationState'; -interface IPageSectionOnChanges extends ng.IOnChangesObject { - visible: ng.IChangesObject; - label: ng.IChangesObject; - badge: ng.IChangesObject; +interface IPageSectionOnChanges extends IOnChangesObject { + visible: IChangesObject; + label: IChangesObject; + badge: IChangesObject; } class PageSectionController implements IController { @@ -15,10 +15,6 @@ class PageSectionController implements IController { public noWrapper: boolean; private pageConfig: INavigationPage; - public constructor(private pageNavigationState: PageNavigationState) { - 'ngInject'; - } - public $onInit(): void { this.visible = this.visible !== false; this.pageConfig = { @@ -27,7 +23,7 @@ class PageSectionController implements IController { visible: this.visible, badge: this.badge, }; - this.pageNavigationState.registerPage(this.pageConfig); + PageNavigationState.registerPage(this.pageConfig); } public $onChanges(changes: IPageSectionOnChanges): void { @@ -43,7 +39,7 @@ class PageSectionController implements IController { } } -class PageSectionComponent implements ng.IComponentOptions { +class PageSectionComponent implements IComponentOptions { public bindings: any = { key: '@', label: '@', diff --git a/app/scripts/modules/core/src/pubsub/PubsubSubscriptionReader.ts b/app/scripts/modules/core/src/pubsub/PubsubSubscriptionReader.ts new file mode 100644 index 00000000000..26d350c4515 --- /dev/null +++ b/app/scripts/modules/core/src/pubsub/PubsubSubscriptionReader.ts @@ -0,0 +1,11 @@ +import { IPromise } from 'angular'; + +import { API, IPubsubSubscription } from '@spinnaker/core'; + +export class PubsubSubscriptionReader { + public static getPubsubSubscriptions(): IPromise { + return API.one('pubsub') + .one('subscriptions') + .get(); + } +} diff --git a/app/scripts/modules/core/src/pubsub/index.ts b/app/scripts/modules/core/src/pubsub/index.ts index 9661b25e9ac..e18be94245b 100644 --- a/app/scripts/modules/core/src/pubsub/index.ts +++ b/app/scripts/modules/core/src/pubsub/index.ts @@ -1 +1 @@ -export * from './pubsubSubscription.service'; +export * from './PubsubSubscriptionReader'; diff --git a/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts b/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts deleted file mode 100644 index aea16d291e6..00000000000 --- a/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { module, IPromise } from 'angular'; - -import { API, IPubsubSubscription } from '@spinnaker/core'; - -export class PubsubSubscriptionService { - public getPubsubSubscriptions(): IPromise { - return API.one('pubsub') - .one('subscriptions') - .get(); - } -} - -export const PUBSUB_SUBSCRIPTION_SERVICE = 'spinnaker.core.pubsubSubscription.service'; -module(PUBSUB_SUBSCRIPTION_SERVICE, []).service('pubsubSubscriptionService', PubsubSubscriptionService); diff --git a/app/scripts/modules/core/src/reactShims/react.injector.ts b/app/scripts/modules/core/src/reactShims/react.injector.ts index 7fc008b60bd..95c54e3f980 100644 --- a/app/scripts/modules/core/src/reactShims/react.injector.ts +++ b/app/scripts/modules/core/src/reactShims/react.injector.ts @@ -9,7 +9,6 @@ import { CancelModalService } from '../cancelModal/cancelModal.service'; import { ConfirmationModalService } from '../confirmationModal/confirmationModal.service'; import { ExecutionDetailsSectionService } from 'core/pipeline/details/executionDetailsSection.service'; import { ExecutionService } from '../pipeline/service/execution.service'; -import { ExecutionsTransformerService } from '../pipeline/service/executions.transformer.service'; import { InfrastructureSearchService } from '../search/infrastructure/infrastructureSearch.service'; import { InfrastructureSearchServiceV2 } from 'core/search/infrastructure/infrastructureSearchV2.service'; import { InsightFilterStateModel } from '../insight/insightFilterState.model'; @@ -52,7 +51,6 @@ export class CoreReactInject extends ReactInject { public get confirmationModalService() { return this.$injector.get('confirmationModalService') as ConfirmationModalService; } public get executionDetailsSectionService() { return this.$injector.get('executionDetailsSectionService') as ExecutionDetailsSectionService; } public get executionService() { return this.$injector.get('executionService') as ExecutionService; } - public get executionsTransformer() { return this.$injector.get('executionsTransformer') as ExecutionsTransformerService; } public get infrastructureSearchService() { return this.$injector.get('infrastructureSearchService') as InfrastructureSearchService; } public get infrastructureSearchServiceV2() { return this.$injector.get('infrastructureSearchServiceV2') as InfrastructureSearchServiceV2; } public get insightFilterStateModel() { return this.$injector.get('insightFilterStateModel') as InsightFilterStateModel; } diff --git a/app/scripts/modules/core/src/securityGroup/securityGroup.dataSource.ts b/app/scripts/modules/core/src/securityGroup/securityGroup.dataSource.ts index 9176f76e425..037745a2d5b 100644 --- a/app/scripts/modules/core/src/securityGroup/securityGroup.dataSource.ts +++ b/app/scripts/modules/core/src/securityGroup/securityGroup.dataSource.ts @@ -4,38 +4,36 @@ import { ApplicationDataSourceRegistry } from 'core/application/service/Applicat import { INFRASTRUCTURE_KEY } from 'core/application/nav/defaultCategories'; import { Application } from 'core/application/application.model'; import { SECURITY_GROUP_READER, SecurityGroupReader } from 'core/securityGroup/securityGroupReader.service'; -import { ENTITY_TAGS_READ_SERVICE, EntityTagsReader } from 'core/entityTag/entityTags.read.service'; +import { EntityTagsReader } from 'core/entityTag/EntityTagsReader'; import { ISecurityGroup } from 'core/domain'; export const SECURITY_GROUP_DATA_SOURCE = 'spinnaker.core.securityGroup.dataSource'; -module(SECURITY_GROUP_DATA_SOURCE, [ENTITY_TAGS_READ_SERVICE, SECURITY_GROUP_READER]).run( - (securityGroupReader: SecurityGroupReader, entityTagsReader: EntityTagsReader) => { - const loadSecurityGroups = (application: Application) => { - return securityGroupReader.loadSecurityGroupsByApplicationName(application.name); - }; +module(SECURITY_GROUP_DATA_SOURCE, [SECURITY_GROUP_READER]).run((securityGroupReader: SecurityGroupReader) => { + const loadSecurityGroups = (application: Application) => { + return securityGroupReader.loadSecurityGroupsByApplicationName(application.name); + }; - const addSecurityGroups = (application: Application, securityGroups: ISecurityGroup[]) => { - return securityGroupReader.getApplicationSecurityGroups(application, securityGroups); - }; + const addSecurityGroups = (application: Application, securityGroups: ISecurityGroup[]) => { + return securityGroupReader.getApplicationSecurityGroups(application, securityGroups); + }; - const addTags = (application: Application) => { - return entityTagsReader.addTagsToSecurityGroups(application); - }; + const addTags = (application: Application) => { + return EntityTagsReader.addTagsToSecurityGroups(application); + }; - ApplicationDataSourceRegistry.registerDataSource({ - key: 'securityGroups', - label: 'Firewalls', - category: INFRASTRUCTURE_KEY, - sref: '.insight.firewalls', - optional: true, - icon: 'fa fa-xs fa-fw fa-lock', - loader: loadSecurityGroups, - onLoad: addSecurityGroups, - afterLoad: addTags, - providerField: 'provider', - credentialsField: 'accountName', - regionField: 'region', - description: 'Network traffic access management', - }); - }, -); + ApplicationDataSourceRegistry.registerDataSource({ + key: 'securityGroups', + label: 'Firewalls', + category: INFRASTRUCTURE_KEY, + sref: '.insight.firewalls', + optional: true, + icon: 'fa fa-xs fa-fw fa-lock', + loader: loadSecurityGroups, + onLoad: addSecurityGroups, + afterLoad: addTags, + providerField: 'provider', + credentialsField: 'accountName', + regionField: 'region', + description: 'Network traffic access management', + }); +}); diff --git a/app/scripts/modules/core/src/securityGroup/securityGroupReader.service.ts b/app/scripts/modules/core/src/securityGroup/securityGroupReader.service.ts index dba35d248de..648df68ce91 100644 --- a/app/scripts/modules/core/src/securityGroup/securityGroupReader.service.ts +++ b/app/scripts/modules/core/src/securityGroup/securityGroupReader.service.ts @@ -10,7 +10,7 @@ import { SECURITY_GROUP_TRANSFORMER_SERVICE, SecurityGroupTransformerService, } from './securityGroupTransformer.service'; -import { ENTITY_TAGS_READ_SERVICE, EntityTagsReader } from 'core/entityTag/entityTags.read.service'; +import { EntityTagsReader } from 'core/entityTag/EntityTagsReader'; import { SETTINGS } from 'core/config/settings'; import { SearchService, ISearchResults } from 'core/search/search.service'; import { ISecurityGroupSearchResult } from './securityGroupSearchResultType'; @@ -278,7 +278,6 @@ export class SecurityGroupReader { private $q: IQService, private securityGroupTransformer: SecurityGroupTransformerService, private providerServiceDelegate: ProviderServiceDelegate, - private entityTagsReader: EntityTagsReader, ) { 'ngInject'; } @@ -377,7 +376,7 @@ export class SecurityGroupReader { }); } if (SETTINGS.feature.entityTags && application.isStandalone) { - return this.entityTagsReader.getEntityTagsForId('securitygroup', details.name).then(tags => { + return EntityTagsReader.getEntityTagsForId('securitygroup', details.name).then(tags => { details.entityTags = tags.find( t => t.entityRef.entityId === details.name && @@ -429,8 +428,7 @@ export class SecurityGroupReader { } export const SECURITY_GROUP_READER = 'spinnaker.core.securityGroup.read.service'; -module(SECURITY_GROUP_READER, [ - SECURITY_GROUP_TRANSFORMER_SERVICE, - PROVIDER_SERVICE_DELEGATE, - ENTITY_TAGS_READ_SERVICE, -]).service('securityGroupReader', SecurityGroupReader); +module(SECURITY_GROUP_READER, [SECURITY_GROUP_TRANSFORMER_SERVICE, PROVIDER_SERVICE_DELEGATE]).service( + 'securityGroupReader', + SecurityGroupReader, +); diff --git a/app/scripts/modules/core/src/serverGroup/serverGroup.dataSource.ts b/app/scripts/modules/core/src/serverGroup/serverGroup.dataSource.ts index 80a2eab68da..86caa9a0357 100644 --- a/app/scripts/modules/core/src/serverGroup/serverGroup.dataSource.ts +++ b/app/scripts/modules/core/src/serverGroup/serverGroup.dataSource.ts @@ -1,7 +1,7 @@ import { module, IQService } from 'angular'; import { ApplicationDataSourceRegistry } from '../application/service/ApplicationDataSourceRegistry'; import { INFRASTRUCTURE_KEY } from 'core/application/nav/defaultCategories'; -import { ENTITY_TAGS_READ_SERVICE, EntityTagsReader } from '../entityTag/entityTags.read.service'; +import { EntityTagsReader } from '../entityTag/EntityTagsReader'; import { CLUSTER_SERVICE, ClusterService } from 'core/cluster/cluster.service'; import { JsonUtils } from 'core/utils'; import { Application } from 'core/application/application.model'; @@ -9,50 +9,44 @@ import { IServerGroup } from 'core/domain'; export const SERVER_GROUP_DATA_SOURCE = 'spinnaker.core.serverGroup.dataSource'; -module(SERVER_GROUP_DATA_SOURCE, [ENTITY_TAGS_READ_SERVICE, CLUSTER_SERVICE]).run( - ( - $q: IQService, - clusterService: ClusterService, - entityTagsReader: EntityTagsReader, - ) => { - const loadServerGroups = (application: Application) => { - return clusterService.loadServerGroups(application); - }; +module(SERVER_GROUP_DATA_SOURCE, [CLUSTER_SERVICE]).run(($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 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); - }; + const addTags = (application: Application) => { + EntityTagsReader.addTagsToServerGroups(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', - loader: loadServerGroups, - onLoad: addServerGroups, - afterLoad: addTags, - providerField: 'type', - credentialsField: 'account', - regionField: 'region', - description: 'Collections of server groups or jobs', - }); - }, -); + 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', + loader: loadServerGroups, + onLoad: addServerGroups, + afterLoad: addTags, + providerField: 'type', + credentialsField: 'account', + regionField: 'region', + description: 'Collections of server groups or jobs', + }); +}); diff --git a/app/scripts/modules/core/src/storage/StorageAccountReader.ts b/app/scripts/modules/core/src/storage/StorageAccountReader.ts new file mode 100644 index 00000000000..cc9f0b2a68c --- /dev/null +++ b/app/scripts/modules/core/src/storage/StorageAccountReader.ts @@ -0,0 +1,9 @@ +import { IPromise } from 'angular'; + +import { API } from 'core/api/ApiService'; + +export class StorageAccountReader { + public static getStorageAccounts(): IPromise { + return API.one('storage').get(); + } +} diff --git a/app/scripts/modules/core/src/storage/index.ts b/app/scripts/modules/core/src/storage/index.ts index b23217ac8d4..fe6de8df139 100644 --- a/app/scripts/modules/core/src/storage/index.ts +++ b/app/scripts/modules/core/src/storage/index.ts @@ -1 +1 @@ -export * from './storageAccount.service'; +export * from './StorageAccountReader'; diff --git a/app/scripts/modules/core/src/storage/storageAccount.service.ts b/app/scripts/modules/core/src/storage/storageAccount.service.ts deleted file mode 100644 index a36aeeabaa4..00000000000 --- a/app/scripts/modules/core/src/storage/storageAccount.service.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { module } from 'angular'; - -import { API } from 'core/api/ApiService'; - -export class StorageAccountService { - public getStorageAccounts(): ng.IPromise { - return API.one('storage').get(); - } -} - -export const STORAGE_ACCOUNT_SERVICE = 'spinnaker.core.storageAccount.service'; -module(STORAGE_ACCOUNT_SERVICE, []).service('storageAccountService', StorageAccountService); diff --git a/app/scripts/modules/core/src/whatsNew/whatsNew.read.service.ts b/app/scripts/modules/core/src/whatsNew/WhatsNewReader.ts similarity index 69% rename from app/scripts/modules/core/src/whatsNew/whatsNew.read.service.ts rename to app/scripts/modules/core/src/whatsNew/WhatsNewReader.ts index 8c1ba70a05c..5843bde2db3 100644 --- a/app/scripts/modules/core/src/whatsNew/whatsNew.read.service.ts +++ b/app/scripts/modules/core/src/whatsNew/WhatsNewReader.ts @@ -1,4 +1,7 @@ -import { module, IHttpService, ILogService, IPromise, IHttpPromiseCallbackArg, IQService } from 'angular'; +import { IPromise, IHttpPromiseCallbackArg } from 'angular'; + +import { $http, $log, $q } from 'ngimport'; + import { SETTINGS } from 'core/config/settings'; export interface IGistApiResponse { @@ -28,23 +31,19 @@ export class WhatsNewReader { return data.files[fileName].content; } - constructor(private $http: IHttpService, private $log: ILogService, private $q: IQService) { - 'ngInject'; - } - - public getWhatsNewContents(): IPromise { + public static getWhatsNewContents(): IPromise { let gistId: string, accessToken: string; gistId = SETTINGS.changelog ? SETTINGS.changelog.gistId : null; accessToken = SETTINGS.changelog ? SETTINGS.changelog.accessToken : null; if (!gistId) { - return this.$q.resolve(null); + return $q.resolve(null); } let url = `https://api.github.com/gists/${gistId}`; if (accessToken) { url += '?access_token=' + accessToken; } - return this.$http + return $http .get(url) .then((result: IHttpPromiseCallbackArg) => { return { @@ -53,11 +52,8 @@ export class WhatsNewReader { }; }) .catch((failure: IHttpPromiseCallbackArg) => { - this.$log.warn(`failed to retrieve gist for what's new dialog:`, failure); + $log.warn(`failed to retrieve gist for what's new dialog:`, failure); return null; }); } } - -export const WHATS_NEW_READ_SERVICE = 'spinnaker.core.whatsNew.read.service'; -module(WHATS_NEW_READ_SERVICE, []).service('whatsNewReader', WhatsNewReader); diff --git a/app/scripts/modules/core/src/whatsNew/whatsNew.directive.js b/app/scripts/modules/core/src/whatsNew/whatsNew.directive.js index 9735be1a2b6..112745fbfdc 100644 --- a/app/scripts/modules/core/src/whatsNew/whatsNew.directive.js +++ b/app/scripts/modules/core/src/whatsNew/whatsNew.directive.js @@ -6,13 +6,13 @@ import { HtmlRenderer, Parser } from 'commonmark'; import { ViewStateCache } from 'core/cache'; import { TIME_FORMATTERS } from 'core/utils/timeFormatters'; -import { WHATS_NEW_READ_SERVICE } from './whatsNew.read.service'; +import { WhatsNewReader } from './WhatsNewReader'; import './whatsNew.less'; module.exports = angular - .module('spinnaker.core.whatsNew.directive', [WHATS_NEW_READ_SERVICE, TIME_FORMATTERS]) - .directive('whatsNew', function(whatsNewReader) { + .module('spinnaker.core.whatsNew.directive', [TIME_FORMATTERS]) + .directive('whatsNew', function() { return { restrict: 'E', replace: true, @@ -30,7 +30,7 @@ module.exports = angular updateLastViewed: null, }; - whatsNewReader.getWhatsNewContents().then(function(result) { + WhatsNewReader.getWhatsNewContents().then(function(result) { if (result) { $scope.fileContents = renderer.render(parser.parse(result.contents)); $scope.fileLastUpdated = result.lastUpdated; diff --git a/app/scripts/modules/core/src/whatsNew/whatsNew.directive.spec.js b/app/scripts/modules/core/src/whatsNew/whatsNew.directive.spec.js index 13a48949642..ddf01f737e7 100644 --- a/app/scripts/modules/core/src/whatsNew/whatsNew.directive.spec.js +++ b/app/scripts/modules/core/src/whatsNew/whatsNew.directive.spec.js @@ -1,6 +1,7 @@ 'use strict'; import { ViewStateCache } from 'core/cache'; +import { WhatsNewReader } from './WhatsNewReader'; describe('Directives: whatsNew', function() { require('./whatsNew.directive.html'); @@ -8,10 +9,9 @@ describe('Directives: whatsNew', function() { beforeEach(window.module(require('./whatsNew.directive').name, require('angular-ui-bootstrap'))); beforeEach( - window.inject(function($rootScope, $compile, whatsNewReader, $q, $filter, $uibModal) { + window.inject(function($rootScope, $compile, $q, $filter, $uibModal) { this.scope = $rootScope.$new(); this.compile = $compile; - this.whatsNewReader = whatsNewReader; this.$filter = $filter; this.$q = $q; this.$uibModal = $uibModal; @@ -38,7 +38,7 @@ describe('Directives: whatsNew', function() { var lastUpdated = new Date().getTime(); var expectedDate = this.$filter('timestamp')(lastUpdated); - spyOn(this.whatsNewReader, 'getWhatsNewContents').and.returnValue( + spyOn(WhatsNewReader, 'getWhatsNewContents').and.returnValue( this.$q.when({ contents: 'stuff', lastUpdated: lastUpdated, @@ -125,7 +125,7 @@ describe('Directives: whatsNew', function() { it('should not render the
    ', function() { var domNode; - spyOn(this.whatsNewReader, 'getWhatsNewContents').and.returnValue(this.$q.when(null)); + spyOn(WhatsNewReader, 'getWhatsNewContents').and.returnValue(this.$q.when(null)); domNode = createWhatsNew(this.compile, this.scope); diff --git a/app/scripts/modules/core/src/whatsNew/whatsNew.read.service.spec.ts b/app/scripts/modules/core/src/whatsNew/whatsNew.read.service.spec.ts index 23c7136bf65..f04d174137e 100644 --- a/app/scripts/modules/core/src/whatsNew/whatsNew.read.service.spec.ts +++ b/app/scripts/modules/core/src/whatsNew/whatsNew.read.service.spec.ts @@ -1,16 +1,12 @@ import { mock, IHttpBackendService } from 'angular'; import { SETTINGS } from 'core/config/settings'; -import { WHATS_NEW_READ_SERVICE, WhatsNewReader, IGistApiResponse, IWhatsNewContents } from './whatsNew.read.service'; +import { WhatsNewReader, IGistApiResponse, IWhatsNewContents } from './WhatsNewReader'; describe('Service: whatsNew reader ', () => { - let reader: WhatsNewReader; let $http: IHttpBackendService; - beforeEach(mock.module(WHATS_NEW_READ_SERVICE)); - beforeEach( - mock.inject((whatsNewReader: WhatsNewReader, $httpBackend: IHttpBackendService) => { - reader = whatsNewReader; + mock.inject(($httpBackend: IHttpBackendService) => { $http = $httpBackend; }), ); @@ -41,7 +37,7 @@ describe('Service: whatsNew reader ', () => { $http.expectGET(url).respond(200, response); - reader.getWhatsNewContents().then((data: IWhatsNewContents) => (result = data)); + WhatsNewReader.getWhatsNewContents().then(data => (result = data)); $http.flush(); expect(result).not.toBeNull(); @@ -52,9 +48,7 @@ describe('Service: whatsNew reader ', () => { it('returns null when gist fetch fails', () => { let result: IWhatsNewContents = { contents: 'fail', lastUpdated: 'never' }; $http.expectGET(url).respond(404, {}); - reader.getWhatsNewContents().then(function(data) { - result = data; - }); + WhatsNewReader.getWhatsNewContents().then(data => (result = data)); $http.flush(); expect(result).toBeNull(); diff --git a/app/scripts/modules/dcos/instance/details/details.controller.js b/app/scripts/modules/dcos/instance/details/details.controller.js index 3ab76a96b1a..5cf83a6d9db 100644 --- a/app/scripts/modules/dcos/instance/details/details.controller.js +++ b/app/scripts/modules/dcos/instance/details/details.controller.js @@ -5,7 +5,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, ServerGroupTemplates, @@ -14,18 +14,13 @@ import { const angular = require('angular'); module.exports = angular - .module('spinnaker.dcos.instance.details.controller', [ - INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, - CONFIRMATION_MODAL_SERVICE, - ]) + .module('spinnaker.dcos.instance.details.controller', [INSTANCE_WRITE_SERVICE, CONFIRMATION_MODAL_SERVICE]) .controller('dcosInstanceDetailsController', function( $scope, $state, $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, dcosProxyUiService, @@ -78,7 +73,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { $scope.state.loading = false; $scope.instance = _.defaults(details, instanceSummary); $scope.instance.account = account; diff --git a/app/scripts/modules/dcos/validation/applicationName.validator.js b/app/scripts/modules/dcos/validation/applicationName.validator.js index 5c38f23e7d2..6d02be05a48 100644 --- a/app/scripts/modules/dcos/validation/applicationName.validator.js +++ b/app/scripts/modules/dcos/validation/applicationName.validator.js @@ -1,11 +1,11 @@ 'use strict'; -import { APPLICATION_NAME_VALIDATOR } from '@spinnaker/core'; +import { ApplicationNameValidator } from '@spinnaker/core'; const angular = require('angular'); module.exports = angular - .module('spinnaker.dcos.validation.applicationName', [APPLICATION_NAME_VALIDATOR]) + .module('spinnaker.dcos.validation.applicationName', []) .factory('dcosApplicationNameValidator', function() { function validateSpecialCharacters(name, errors) { let pattern = /^[a-z0-9]+$/; @@ -46,6 +46,6 @@ module.exports = angular validate: validate, }; }) - .run(function(applicationNameValidator, dcosApplicationNameValidator) { - applicationNameValidator.registerValidator('dcos', dcosApplicationNameValidator); + .run(function(dcosApplicationNameValidator) { + ApplicationNameValidator.registerValidator('dcos', dcosApplicationNameValidator); }); diff --git a/app/scripts/modules/ecs/instance/details/instance.details.controller.js b/app/scripts/modules/ecs/instance/details/instance.details.controller.js index f7ef67662f6..4c348218954 100644 --- a/app/scripts/modules/ecs/instance/details/instance.details.controller.js +++ b/app/scripts/modules/ecs/instance/details/instance.details.controller.js @@ -6,7 +6,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, + InstanceReader, RecentHistoryService, SETTINGS, } from '@spinnaker/core'; @@ -15,7 +15,6 @@ module.exports = angular .module('spinnaker.ecs.instance.details.controller', [ require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, ]) .controller('ecsInstanceDetailsCtrl', function( @@ -23,7 +22,6 @@ module.exports = angular $state, $uibModal, confirmationModalService, - instanceReader, instanceWriter, instance, app, @@ -172,7 +170,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { if ($scope.$$destroyed) { return; } diff --git a/app/scripts/modules/google/src/instance/details/instance.details.controller.js b/app/scripts/modules/google/src/instance/details/instance.details.controller.js index dd8f4dc3e99..1caf4043c4f 100644 --- a/app/scripts/modules/google/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/google/src/instance/details/instance.details.controller.js @@ -7,7 +7,7 @@ import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, FirewallLabels, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, } from '@spinnaker/core'; @@ -20,7 +20,6 @@ module.exports = angular require('angular-ui-bootstrap'), require('google/common/xpnNaming.gce.service.js').name, INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, GCE_HTTP_LOAD_BALANCER_UTILS, ]) @@ -30,7 +29,6 @@ module.exports = angular $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, moniker, @@ -141,7 +139,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { $scope.state.loading = false; extractHealthMetrics(instanceSummary, details); $scope.instance = _.defaults(details, instanceSummary); diff --git a/app/scripts/modules/google/src/validation/applicationName.validator.js b/app/scripts/modules/google/src/validation/applicationName.validator.js index cfcd6a2a63d..fecb936d478 100644 --- a/app/scripts/modules/google/src/validation/applicationName.validator.js +++ b/app/scripts/modules/google/src/validation/applicationName.validator.js @@ -2,10 +2,10 @@ const angular = require('angular'); -import { APPLICATION_NAME_VALIDATOR, FirewallLabels } from '@spinnaker/core'; +import { ApplicationNameValidator, FirewallLabels } from '@spinnaker/core'; module.exports = angular - .module('spinnaker.gce.validation.applicationName', [APPLICATION_NAME_VALIDATOR]) + .module('spinnaker.gce.validation.applicationName', []) .factory('gceApplicationNameValidator', function() { function validateSpecialCharacters(name, errors) { let pattern = /^([a-zA-Z][a-zA-Z0-9]*)?$/; @@ -105,6 +105,6 @@ module.exports = angular validate: validate, }; }) - .run(function(applicationNameValidator, gceApplicationNameValidator) { - applicationNameValidator.registerValidator('gce', gceApplicationNameValidator); + .run(function(gceApplicationNameValidator) { + ApplicationNameValidator.registerValidator('gce', gceApplicationNameValidator); }); diff --git a/app/scripts/modules/kubernetes/src/instance/details/details.controller.js b/app/scripts/modules/kubernetes/src/instance/details/details.controller.js index 981d104d41c..7b1b9b01f01 100644 --- a/app/scripts/modules/kubernetes/src/instance/details/details.controller.js +++ b/app/scripts/modules/kubernetes/src/instance/details/details.controller.js @@ -6,7 +6,7 @@ import _ from 'lodash'; import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, ServerGroupTemplates, @@ -17,7 +17,6 @@ module.exports = angular require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, ]) .controller('kubernetesInstanceDetailsController', function( @@ -26,7 +25,6 @@ module.exports = angular $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, moniker, @@ -125,7 +123,7 @@ module.exports = angular extraData.account = account; extraData.namespace = namespace; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, namespace, instance.instanceId).then(function(details) { + return InstanceReader.getInstanceDetails(account, namespace, instance.instanceId).then(function(details) { $scope.state.loading = false; $scope.instance = _.defaults(details, instanceSummary); $scope.instance.account = account; diff --git a/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts b/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts index 7dee36b0467..fb0cf79c78a 100644 --- a/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/instance/details/details.controller.ts @@ -5,7 +5,6 @@ import { flattenDeep } from 'lodash'; import { Application, CONFIRMATION_MODAL_SERVICE, - INSTANCE_READ_SERVICE, InstanceReader, RecentHistoryService, IManifest, @@ -37,7 +36,6 @@ class KubernetesInstanceDetailsController implements IController { private $q: IQService, private $scope: IScope, private app: Application, - private instanceReader: InstanceReader, ) { 'ngInject'; @@ -120,18 +118,20 @@ class KubernetesInstanceDetailsController implements IController { } RecentHistoryService.addExtraDataToLatest('instances', recentHistoryExtraData); - return this.instanceReader - .getInstanceDetails(instanceManager.account, instanceManager.region, instance.instanceId) - .then((instanceDetails: IKubernetesInstance) => { - instanceDetails.account = instanceManager.account; - instanceDetails.namespace = instanceDetails.manifest.metadata.namespace; - instanceDetails.displayName = instanceDetails.manifest.metadata.name; - instanceDetails.kind = instanceDetails.manifest.kind; - instanceDetails.apiVersion = instanceDetails.manifest.apiVersion; - instanceDetails.id = instanceDetails.name; - instanceDetails.provider = 'kubernetes'; - return instanceDetails; - }); + return InstanceReader.getInstanceDetails( + instanceManager.account, + instanceManager.region, + instance.instanceId, + ).then((instanceDetails: IKubernetesInstance) => { + instanceDetails.account = instanceManager.account; + instanceDetails.namespace = instanceDetails.manifest.metadata.namespace; + instanceDetails.displayName = instanceDetails.manifest.metadata.name; + instanceDetails.kind = instanceDetails.manifest.kind; + instanceDetails.apiVersion = instanceDetails.manifest.apiVersion; + instanceDetails.id = instanceDetails.name; + instanceDetails.provider = 'kubernetes'; + return instanceDetails; + }); } else { return this.$q.reject(); } @@ -140,7 +140,7 @@ class KubernetesInstanceDetailsController implements IController { export const KUBERNETES_V2_INSTANCE_DETAILS_CTRL = 'spinnaker.kubernetes.v2.instanceDetails.controller'; -module(KUBERNETES_V2_INSTANCE_DETAILS_CTRL, [CONFIRMATION_MODAL_SERVICE, INSTANCE_READ_SERVICE]).controller( +module(KUBERNETES_V2_INSTANCE_DETAILS_CTRL, [CONFIRMATION_MODAL_SERVICE]).controller( 'kubernetesV2InstanceDetailsCtrl', KubernetesInstanceDetailsController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/delete/delete.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/delete/delete.controller.ts index 413b85101da..f1484ee1bde 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/delete/delete.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/delete/delete.controller.ts @@ -1,7 +1,7 @@ import { copy, IController, module } from 'angular'; import { IModalServiceInstance } from 'angular-ui-bootstrap'; -import { Application, MANIFEST_WRITER, ManifestWriter, TaskMonitor } from '@spinnaker/core'; +import { Application, ManifestWriter, TaskMonitor } from '@spinnaker/core'; import { IManifestCoordinates } from '../IManifestCoordinates'; import { KUBERNETES_DELETE_MANIFEST_OPTIONS_FORM } from './deleteOptionsForm.component'; @@ -28,7 +28,6 @@ class KubernetesManifestDeleteController implements IController { constructor( coordinates: IManifestCoordinates, private $uibModalInstance: IModalServiceInstance, - private manifestWriter: ManifestWriter, private application: Application, public manifestController: string, ) { @@ -67,14 +66,14 @@ class KubernetesManifestDeleteController implements IController { payload.options.orphanDependants = !payload.options.cascading; delete payload.options.cascading; - return this.manifestWriter.deleteManifest(payload, this.application); + return ManifestWriter.deleteManifest(payload, this.application); }); } } export const KUBERNETES_MANIFEST_DELETE_CTRL = 'spinnaker.kubernetes.v2.manifest.delete.controller'; -module(KUBERNETES_MANIFEST_DELETE_CTRL, [MANIFEST_WRITER, KUBERNETES_DELETE_MANIFEST_OPTIONS_FORM]).controller( +module(KUBERNETES_MANIFEST_DELETE_CTRL, [KUBERNETES_DELETE_MANIFEST_OPTIONS_FORM]).controller( 'kubernetesV2ManifestDeleteCtrl', KubernetesManifestDeleteController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/edit/editManifestWizard.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/edit/editManifestWizard.controller.ts index f0186d89191..7f5df094f1f 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/edit/editManifestWizard.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/edit/editManifestWizard.controller.ts @@ -23,7 +23,6 @@ class KubernetesEditManifestCtrl implements IController { sourceMoniker: IMoniker, private $uibModalInstance: IModalInstanceService, private application: Application, - private manifestWriter: ManifestWriter, ) { 'ngInject'; KubernetesManifestCommandBuilder.buildNewManifestCommand(application, sourceManifest, sourceMoniker).then( @@ -45,7 +44,7 @@ class KubernetesEditManifestCtrl implements IController { public submit(): void { const command = KubernetesManifestCommandBuilder.copyAndCleanCommand(this.metadata, this.command); - const submitMethod = () => this.manifestWriter.deployManifest(command, this.application); + const submitMethod = () => ManifestWriter.deployManifest(command, this.application); this.taskMonitor.submit(submitMethod); } diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/pause.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/pause.controller.ts index 88ac7d8a482..d9a2eaca3aa 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/pause.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/pause.controller.ts @@ -1,7 +1,7 @@ import { copy, IController, module } from 'angular'; import { IModalServiceInstance } from 'angular-ui-bootstrap'; -import { Application, MANIFEST_WRITER, ManifestWriter, TaskMonitor } from '@spinnaker/core'; +import { Application, ManifestWriter, TaskMonitor } from '@spinnaker/core'; import { IManifestCoordinates } from '../IManifestCoordinates'; interface IPauseRolloutCommand { @@ -21,7 +21,6 @@ class KubernetesManifestPauseRolloutController implements IController { constructor( coordinates: IManifestCoordinates, private $uibModalInstance: IModalServiceInstance, - private manifestWriter: ManifestWriter, private application: Application, ) { 'ngInject'; @@ -53,14 +52,14 @@ class KubernetesManifestPauseRolloutController implements IController { const payload = copy(this.command) as any; payload.cloudProvider = 'kubernetes'; - return this.manifestWriter.pauseRolloutManifest(payload, this.application); + return ManifestWriter.pauseRolloutManifest(payload, this.application); }); } } export const KUBERNETES_MANIFEST_PAUSE_ROLLOUT_CTRL = 'spinnaker.kubernetes.v2.manifest.pauseRollout.controller'; -module(KUBERNETES_MANIFEST_PAUSE_ROLLOUT_CTRL, [MANIFEST_WRITER]).controller( +module(KUBERNETES_MANIFEST_PAUSE_ROLLOUT_CTRL, []).controller( 'kubernetesV2ManifestPauseRolloutCtrl', KubernetesManifestPauseRolloutController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/resume.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/resume.controller.ts index 883d8e8fd94..278dab95b5e 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/resume.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/resume.controller.ts @@ -1,7 +1,7 @@ import { copy, IController, module } from 'angular'; import { IModalServiceInstance } from 'angular-ui-bootstrap'; -import { Application, MANIFEST_WRITER, ManifestWriter, TaskMonitor } from '@spinnaker/core'; +import { Application, ManifestWriter, TaskMonitor } from '@spinnaker/core'; import { IManifestCoordinates } from '../IManifestCoordinates'; interface IResumeRolloutCommand { @@ -21,7 +21,6 @@ class KubernetesManifestResumeRolloutController implements IController { constructor( coordinates: IManifestCoordinates, private $uibModalInstance: IModalServiceInstance, - private manifestWriter: ManifestWriter, private application: Application, ) { 'ngInject'; @@ -53,14 +52,14 @@ class KubernetesManifestResumeRolloutController implements IController { const payload = copy(this.command) as any; payload.cloudProvider = 'kubernetes'; - return this.manifestWriter.resumeRolloutManifest(payload, this.application); + return ManifestWriter.resumeRolloutManifest(payload, this.application); }); } } export const KUBERNETES_MANIFEST_RESUME_ROLLOUT_CTRL = 'spinnaker.kubernetes.v2.manifest.resumeRollout.controller'; -module(KUBERNETES_MANIFEST_RESUME_ROLLOUT_CTRL, [MANIFEST_WRITER]).controller( +module(KUBERNETES_MANIFEST_RESUME_ROLLOUT_CTRL, []).controller( 'kubernetesV2ManifestResumeRolloutCtrl', KubernetesManifestResumeRolloutController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/undo.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/undo.controller.ts index b1f776cb0ff..dcddc0374e8 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/rollout/undo.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/rollout/undo.controller.ts @@ -1,7 +1,7 @@ import { copy, IController, module } from 'angular'; import { IModalServiceInstance } from 'angular-ui-bootstrap'; -import { Application, MANIFEST_WRITER, ManifestWriter, TaskMonitor } from '@spinnaker/core'; +import { Application, ManifestWriter, TaskMonitor } from '@spinnaker/core'; import { IManifestCoordinates } from '../IManifestCoordinates'; interface IUndoRolloutCommand { @@ -28,7 +28,6 @@ class KubernetesManifestUndoRolloutController implements IController { coordinates: IManifestCoordinates, public revisions: IRolloutRevision[], private $uibModalInstance: IModalServiceInstance, - private manifestWriter: ManifestWriter, private application: Application, ) { 'ngInject'; @@ -61,14 +60,14 @@ class KubernetesManifestUndoRolloutController implements IController { const payload = copy(this.command) as any; payload.cloudProvider = 'kubernetes'; - return this.manifestWriter.undoRolloutManifest(payload, this.application); + return ManifestWriter.undoRolloutManifest(payload, this.application); }); } } export const KUBERNETES_MANIFEST_UNDO_ROLLOUT_CTRL = 'spinnaker.kubernetes.v2.manifest.undoRollout.controller'; -module(KUBERNETES_MANIFEST_UNDO_ROLLOUT_CTRL, [MANIFEST_WRITER]).controller( +module(KUBERNETES_MANIFEST_UNDO_ROLLOUT_CTRL, []).controller( 'kubernetesV2ManifestUndoRolloutCtrl', KubernetesManifestUndoRolloutController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/scale/scale.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/scale/scale.controller.ts index 5c9c494e62b..85fd1bbb1e0 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/scale/scale.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/scale/scale.controller.ts @@ -1,7 +1,7 @@ import { copy, IController, module } from 'angular'; import { IModalServiceInstance } from 'angular-ui-bootstrap'; -import { Application, MANIFEST_WRITER, ManifestWriter, TaskMonitor } from '@spinnaker/core'; +import { Application, ManifestWriter, TaskMonitor } from '@spinnaker/core'; import { IManifestCoordinates } from '../IManifestCoordinates'; import { KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM } from './scaleSettingsForm.component'; @@ -24,7 +24,6 @@ class KubernetesManifestScaleController implements IController { coordinates: IManifestCoordinates, currentReplicas: number, private $uibModalInstance: IModalServiceInstance, - private manifestWriter: ManifestWriter, private application: Application, ) { 'ngInject'; @@ -57,14 +56,14 @@ class KubernetesManifestScaleController implements IController { const payload = copy(this.command) as any; payload.cloudProvider = 'kubernetes'; - return this.manifestWriter.scaleManifest(payload, this.application); + return ManifestWriter.scaleManifest(payload, this.application); }); } } export const KUBERNETES_MANIFEST_SCALE_CTRL = 'spinnaker.kubernetes.v2.manifest.scale.controller'; -module(KUBERNETES_MANIFEST_SCALE_CTRL, [MANIFEST_WRITER, KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM]).controller( +module(KUBERNETES_MANIFEST_SCALE_CTRL, [KUBERNETES_SCALE_MANIFEST_SETTINGS_FORM]).controller( 'kubernetesV2ManifestScaleCtrl', KubernetesManifestScaleController, ); diff --git a/app/scripts/modules/kubernetes/src/v2/manifest/wizard/manifestWizard.controller.ts b/app/scripts/modules/kubernetes/src/v2/manifest/wizard/manifestWizard.controller.ts index d35fe28ac14..db5e13181e9 100644 --- a/app/scripts/modules/kubernetes/src/v2/manifest/wizard/manifestWizard.controller.ts +++ b/app/scripts/modules/kubernetes/src/v2/manifest/wizard/manifestWizard.controller.ts @@ -18,11 +18,7 @@ class KubernetesManifestWizardCtrl implements IController { public command: IKubernetesManifestCommand; public metadata: IKubernetesManifestCommandMetadata; - constructor( - private $uibModalInstance: IModalInstanceService, - private application: Application, - private manifestWriter: ManifestWriter, - ) { + constructor(private $uibModalInstance: IModalInstanceService, private application: Application) { 'ngInject'; KubernetesManifestCommandBuilder.buildNewManifestCommand(application).then(builtCommand => { const { command, metadata } = builtCommand; @@ -40,7 +36,7 @@ class KubernetesManifestWizardCtrl implements IController { public submit(): void { const command = KubernetesManifestCommandBuilder.copyAndCleanCommand(this.metadata, this.command); - const submitMethod = () => this.manifestWriter.deployManifest(command, this.application); + const submitMethod = () => ManifestWriter.deployManifest(command, this.application); this.taskMonitor.submit(submitMethod); } diff --git a/app/scripts/modules/kubernetes/src/validation/applicationName.validator.js b/app/scripts/modules/kubernetes/src/validation/applicationName.validator.js index e21dacb2c6f..0be783fb617 100644 --- a/app/scripts/modules/kubernetes/src/validation/applicationName.validator.js +++ b/app/scripts/modules/kubernetes/src/validation/applicationName.validator.js @@ -2,10 +2,10 @@ const angular = require('angular'); -import { APPLICATION_NAME_VALIDATOR } from '@spinnaker/core'; +import { ApplicationNameValidator } from '@spinnaker/core'; module.exports = angular - .module('spinnaker.kubernetes.validation.applicationName', [APPLICATION_NAME_VALIDATOR]) + .module('spinnaker.kubernetes.validation.applicationName', []) .factory('kubernetesApplicationNameValidator', function() { function validateSpecialCharacters(name, warnings, errors) { const alphanumPattern = /^([a-zA-Z][a-zA-Z0-9]*)?$/; @@ -70,6 +70,6 @@ module.exports = angular validate: validate, }; }) - .run(function(applicationNameValidator, kubernetesApplicationNameValidator) { - applicationNameValidator.registerValidator('kubernetes', kubernetesApplicationNameValidator); + .run(function(kubernetesApplicationNameValidator) { + ApplicationNameValidator.registerValidator('kubernetes', kubernetesApplicationNameValidator); }); diff --git a/app/scripts/modules/openstack/src/instance/details/instance.details.controller.js b/app/scripts/modules/openstack/src/instance/details/instance.details.controller.js index 16f3272e96f..26f859fb7f8 100644 --- a/app/scripts/modules/openstack/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/openstack/src/instance/details/instance.details.controller.js @@ -7,7 +7,7 @@ import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, FirewallLabels, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, SETTINGS, @@ -18,7 +18,6 @@ module.exports = angular require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, ]) .controller('openstackInstanceDetailsCtrl', function( @@ -27,7 +26,6 @@ module.exports = angular $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, moniker, @@ -139,7 +137,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(details => { if ($scope.$$destroyed) { return; } diff --git a/app/scripts/modules/openstack/src/validation/applicationName.validator.js b/app/scripts/modules/openstack/src/validation/applicationName.validator.js index a55c0022f54..47b8611a155 100644 --- a/app/scripts/modules/openstack/src/validation/applicationName.validator.js +++ b/app/scripts/modules/openstack/src/validation/applicationName.validator.js @@ -2,10 +2,10 @@ const angular = require('angular'); -import { APPLICATION_NAME_VALIDATOR, FirewallLabels } from '@spinnaker/core'; +import { ApplicationNameValidator, FirewallLabels } from '@spinnaker/core'; module.exports = angular - .module('spinnaker.openstack.validation.applicationName', [APPLICATION_NAME_VALIDATOR]) + .module('spinnaker.openstack.validation.applicationName', []) .factory('openstackApplicationNameValidator', function() { function validateSpecialCharacters(name, errors) { let pattern = /^[a-zA-Z_0-9.]*$/g; @@ -53,6 +53,6 @@ module.exports = angular validate: validate, }; }) - .run(function(applicationNameValidator, openstackApplicationNameValidator) { - applicationNameValidator.registerValidator('openstack', openstackApplicationNameValidator); + .run(function(openstackApplicationNameValidator) { + ApplicationNameValidator.registerValidator('openstack', openstackApplicationNameValidator); }); diff --git a/app/scripts/modules/oracle/instance/details/instance.details.controller.js b/app/scripts/modules/oracle/instance/details/instance.details.controller.js index c72f777fc5a..bd437f0cc18 100644 --- a/app/scripts/modules/oracle/instance/details/instance.details.controller.js +++ b/app/scripts/modules/oracle/instance/details/instance.details.controller.js @@ -2,15 +2,14 @@ const angular = require('angular'); -import { INSTANCE_READ_SERVICE, INSTANCE_WRITE_SERVICE } from '@spinnaker/core'; +import { INSTANCE_WRITE_SERVICE } from '@spinnaker/core'; module.exports = angular .module('spinnaker.oraclebmcs.instance.details.controller', [ require('@uirouter/angularjs').default, INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, ]) - .controller('oraclebmcsInstanceDetailsCtrl', function($scope, $q, instanceWriter, instanceReader, app, instance) { + .controller('oraclebmcsInstanceDetailsCtrl', function($scope, $q, instanceWriter, app, instance) { $scope.application = app; let initialize = app.isStandalone ? retrieveInstance() : $q.all([app.serverGroups.ready()]).then(retrieveInstance); @@ -41,7 +40,7 @@ module.exports = angular } $scope.instance = instanceSummary; - instanceReader.getInstanceDetails(account, region, instance.instanceId).then(instanceDetails => { + InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(instanceDetails => { Object.assign($scope.instance, instanceDetails); }); } diff --git a/app/scripts/modules/titus/src/instance/details/instance.details.controller.js b/app/scripts/modules/titus/src/instance/details/instance.details.controller.js index b56b33410c8..6a978b875e6 100644 --- a/app/scripts/modules/titus/src/instance/details/instance.details.controller.js +++ b/app/scripts/modules/titus/src/instance/details/instance.details.controller.js @@ -8,7 +8,7 @@ import { CloudProviderRegistry, CONFIRMATION_MODAL_SERVICE, FirewallLabels, - INSTANCE_READ_SERVICE, + InstanceReader, INSTANCE_WRITE_SERVICE, RecentHistoryService, SETTINGS, @@ -19,7 +19,6 @@ module.exports = angular require('@uirouter/angularjs').default, require('angular-ui-bootstrap'), INSTANCE_WRITE_SERVICE, - INSTANCE_READ_SERVICE, CONFIRMATION_MODAL_SERVICE, require('../../securityGroup/securityGroup.read.service').name, ]) @@ -30,7 +29,6 @@ module.exports = angular $uibModal, instanceWriter, confirmationModalService, - instanceReader, instance, app, moniker, @@ -96,7 +94,7 @@ module.exports = angular extraData.account = account; extraData.region = region; RecentHistoryService.addExtraDataToLatest('instances', extraData); - return instanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { + return InstanceReader.getInstanceDetails(account, region, instance.instanceId).then(function(details) { $scope.state.loading = false; extractHealthMetrics(instanceSummary, details); $scope.instance = defaults(details, instanceSummary); diff --git a/app/scripts/modules/titus/src/titus.module.ts b/app/scripts/modules/titus/src/titus.module.ts index 205b7527ad7..26598db5ec9 100644 --- a/app/scripts/modules/titus/src/titus.module.ts +++ b/app/scripts/modules/titus/src/titus.module.ts @@ -3,7 +3,7 @@ import { module } from 'angular'; import { CloudProviderRegistry, DeploymentStrategyRegistry } from '@spinnaker/core'; import { TITUS_MIGRATION_CONFIG_COMPONENT } from './migration/titusMigrationConfig.component'; -import { TITUS_APPLICATION_NAME_VALIDATOR } from './validation/applicationName.validator'; +import './validation/ApplicationNameValidator'; import './help/titus.help'; import { TITUS_REACT_MODULE } from './reactShims/titus.react.module'; @@ -27,7 +27,6 @@ module(TITUS_MODULE, [ require('./serverGroup/configure/serverGroup.configure.titus.module.js').name, require('./serverGroup/serverGroup.transformer.js').name, require('./instance/details/instance.details.controller.js').name, - TITUS_APPLICATION_NAME_VALIDATOR, require('./pipeline/stages/findAmi/titusFindAmiStage.js').name, require('./pipeline/stages/runJob/titusRunJobStage.js').name, require('./pipeline/stages/enableAsg/titusEnableAsgStage.js').name, diff --git a/app/scripts/modules/titus/src/validation/applicationName.validator.ts b/app/scripts/modules/titus/src/validation/ApplicationNameValidator.ts similarity index 66% rename from app/scripts/modules/titus/src/validation/applicationName.validator.ts rename to app/scripts/modules/titus/src/validation/ApplicationNameValidator.ts index 154a84e4394..f9a8f4b4fa2 100644 --- a/app/scripts/modules/titus/src/validation/applicationName.validator.ts +++ b/app/scripts/modules/titus/src/validation/ApplicationNameValidator.ts @@ -1,11 +1,4 @@ -import { module } from 'angular'; - -import { - APPLICATION_NAME_VALIDATOR, - ApplicationNameValidator, - FirewallLabels, - IApplicationNameValidator, -} from '@spinnaker/core'; +import { ApplicationNameValidator, FirewallLabels, IApplicationNameValidator } from '@spinnaker/core'; class TitusApplicationNameValidator implements IApplicationNameValidator { private validateSpecialCharacters(name: string, errors: string[]): void { @@ -46,12 +39,4 @@ class TitusApplicationNameValidator implements IApplicationNameValidator { } } -export const TITUS_APPLICATION_NAME_VALIDATOR = 'spinnaker.titus.validation.applicationName'; - -module(TITUS_APPLICATION_NAME_VALIDATOR, [APPLICATION_NAME_VALIDATOR]) - .service('titusApplicationNameValidator', TitusApplicationNameValidator) - .run( - (applicationNameValidator: ApplicationNameValidator, titusApplicationNameValidator: IApplicationNameValidator) => { - applicationNameValidator.registerValidator('titus', titusApplicationNameValidator); - }, - ); +ApplicationNameValidator.registerValidator('titus', new TitusApplicationNameValidator());