From 963e3f0d3890020b9d0f0e6499c3ee2647e5888e Mon Sep 17 00:00:00 2001 From: Isaac Mosquera Date: Mon, 16 Oct 2017 13:49:42 -0700 Subject: [PATCH] feat(moniker) - adding monikers to the deploy stage (#4268) --- .../serverGroupCommandBuilder.service.js | 4 ++-- .../serverGroupConfiguration.service.ts | 17 ++++++++++++++++- .../common/serverGroupCommandBuilder.service.ts | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupCommandBuilder.service.js b/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupCommandBuilder.service.js index 8107a167f2d..4d558337335 100644 --- a/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupCommandBuilder.service.js +++ b/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupCommandBuilder.service.js @@ -45,7 +45,7 @@ module.exports = angular.module('spinnaker.amazon.serverGroupCommandBuilder.serv var useAmiBlockDeviceMappings = applicationAwsSettings.useAmiBlockDeviceMappings || false; var command = { - application: application.name, + application: application, credentials: defaultCredentials, region: defaultRegion, strategy: '', @@ -189,7 +189,7 @@ module.exports = angular.module('spinnaker.amazon.serverGroupCommandBuilder.serv var useAmiBlockDeviceMappings = applicationAwsSettings.useAmiBlockDeviceMappings || false; var command = { - application: application.name, + application: application, strategy: '', stack: serverGroupName.stack, freeFormDetails: serverGroupName.freeFormDetails, diff --git a/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupConfiguration.service.ts b/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupConfiguration.service.ts index 84d3634c24f..47abf258d54 100644 --- a/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupConfiguration.service.ts +++ b/app/scripts/modules/amazon/src/serverGroup/configure/serverGroupConfiguration.service.ts @@ -1,5 +1,5 @@ import { module, IPromise, IQService } from 'angular'; -import { chain, clone, cloneDeep, extend, find, flatten, has, intersection, keys, map, some, xor } from 'lodash'; +import { chain, clone, cloneDeep, extend, find, flatten, has, intersection, isNil, keys, map, some, xor } from 'lodash'; import { ACCOUNT_SERVICE, @@ -29,6 +29,8 @@ import { import { IAmazonLoadBalancer, IKeyPair } from 'amazon/domain'; import { KEY_PAIRS_READ_SERVICE, KeyPairsReader } from 'amazon/keyPairs/keyPairs.read.service'; +import { IMoniker } from 'core/naming/IMoniker'; +import { NamingService } from 'core/naming/naming.service'; export type IBlockDeviceMappingSource = 'source' | 'ami' | 'default'; @@ -66,6 +68,7 @@ export interface IAmazonServerGroupCommand extends IServerGroupCommand { getBlockDeviceMappingsSource: () => IBlockDeviceMappingSource; selectBlockDeviceMappingsSource: (selection: string) => void; usePreferredZonesChanged: () => IAmazonServerGroupCommandResult; + clusterChanged: () => void; } export class AwsServerGroupConfigurationService { @@ -82,6 +85,7 @@ export class AwsServerGroupConfigurationService { private subnetReader: SubnetReader, private keyPairsReader: KeyPairsReader, private loadBalancerReader: LoadBalancerReader, + private namingService: NamingService, private serverGroupCommandRegistry: ServerGroupCommandRegistry, private autoScalingProcessService: any) { 'ngInject'; @@ -567,6 +571,17 @@ export class AwsServerGroupConfigurationService { return result; }; + command.clusterChanged = (): void => { + const appName = isNil(command.application) ? undefined : command.application.name; + const moniker: IMoniker = { + app: appName, + stack: command.stack, + detail: command.freeFormDetails, + cluster: this.namingService.getClusterName(appName, command.stack, command.freeFormDetails) + }; + command.moniker = moniker; + }; + command.credentialsChanged = (): IServerGroupCommandResult => { const result: IAmazonServerGroupCommandResult = { dirty: {} }; const backingData = command.backingData; diff --git a/app/scripts/modules/core/src/serverGroup/configure/common/serverGroupCommandBuilder.service.ts b/app/scripts/modules/core/src/serverGroup/configure/common/serverGroupCommandBuilder.service.ts index 3163d3aa0d4..9b20615331b 100644 --- a/app/scripts/modules/core/src/serverGroup/configure/common/serverGroupCommandBuilder.service.ts +++ b/app/scripts/modules/core/src/serverGroup/configure/common/serverGroupCommandBuilder.service.ts @@ -1,6 +1,7 @@ import {module} from 'angular'; import { Application } from 'core/application/application.model'; +import { IMoniker } from 'core/naming/IMoniker'; import { ILoadBalancer, ISecurityGroup, ISubnet, IEntityTags } from 'core/domain'; import { ICapacity } from 'core/serverGroup/serverGroupWriter.service'; import { IDeploymentStrategy } from 'core/deploymentStrategy'; @@ -95,6 +96,7 @@ export interface IServerGroupCommand extends IServerGroupCommandResult { asgName: string; }; stack?: string; + moniker?: IMoniker; strategy: string; subnetType: string; suspendedProcesses: string[];