From 9141d19377c2da19b5336ab5fd8a3af4600ba04b Mon Sep 17 00:00:00 2001 From: Isaac Mosquera Date: Mon, 16 Oct 2017 21:57:50 -0700 Subject: [PATCH] feat(moniker) - adding monikers to load balancers (#4278) --- .../createAmazonLoadBalancer.controller.ts | 23 +++++++++++++++---- .../modules/core/src/domain/ILoadBalancer.ts | 2 ++ .../loadBalancer.write.service.ts | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/scripts/modules/amazon/src/loadBalancer/configure/common/createAmazonLoadBalancer.controller.ts b/app/scripts/modules/amazon/src/loadBalancer/configure/common/createAmazonLoadBalancer.controller.ts index f6971150544..0d079b6f206 100644 --- a/app/scripts/modules/amazon/src/loadBalancer/configure/common/createAmazonLoadBalancer.controller.ts +++ b/app/scripts/modules/amazon/src/loadBalancer/configure/common/createAmazonLoadBalancer.controller.ts @@ -1,7 +1,8 @@ import { IScope, IPromise } from 'angular'; import { IModalInstanceService } from 'angular-ui-bootstrap'; import { StateService } from '@uirouter/angularjs'; -import { chain, clone, cloneDeep, find, filter, map, trimEnd, uniq, values } from 'lodash'; +import { chain, clone, cloneDeep, find, filter, isNil, map, trimEnd, uniq, values } from 'lodash'; +import { IMoniker } from 'core/naming/IMoniker'; import { AccountService, @@ -142,9 +143,14 @@ export abstract class CreateAmazonLoadBalancerCtrl { } protected buildName(): void { - const nameParts = this.namingService.parseLoadBalancerName(this.loadBalancerCommand.name); - this.loadBalancerCommand.stack = nameParts.stack; - this.loadBalancerCommand.detail = nameParts.freeFormDetails; + if (isNil(this.loadBalancerCommand.moniker)) { + const nameParts = this.namingService.parseLoadBalancerName(this.loadBalancerCommand.name); + this.loadBalancerCommand.stack = nameParts.stack; + this.loadBalancerCommand.detail = nameParts.freeFormDetails; + } else { + this.loadBalancerCommand.stack = this.loadBalancerCommand.moniker.stack; + this.loadBalancerCommand.detail = this.loadBalancerCommand.moniker.detail; + } delete this.loadBalancerCommand.name; } @@ -356,6 +362,14 @@ export abstract class CreateAmazonLoadBalancerCtrl { } private updateName(): void { + const elb = this.loadBalancerCommand; + const moniker: IMoniker = { + app: this.application.name, + cluster: this.getName(), + stack: elb.stack, + detail: elb.detail + }; + this.loadBalancerCommand.moniker = moniker; this.loadBalancerCommand.name = this.getName(); }; @@ -419,7 +433,6 @@ export abstract class CreateAmazonLoadBalancerCtrl { public submit(): void { const descriptor = this.isNew ? 'Create' : 'Update'; const loadBalancerCommandFormatted = cloneDeep(this.loadBalancerCommand); - if (this.forPipelineConfig) { // don't submit to backend for creation. Just return the loadBalancerCommand object this.formatListeners(loadBalancerCommandFormatted).then(() => { diff --git a/app/scripts/modules/core/src/domain/ILoadBalancer.ts b/app/scripts/modules/core/src/domain/ILoadBalancer.ts index d6470846a85..a9ec2de58f2 100644 --- a/app/scripts/modules/core/src/domain/ILoadBalancer.ts +++ b/app/scripts/modules/core/src/domain/ILoadBalancer.ts @@ -2,6 +2,7 @@ import { IInstance } from './IInstance'; import { IInstanceCounts } from './IInstanceCounts'; import { IServerGroup } from './IServerGroup'; import { ITaggedEntity } from './ITaggedEntity'; +import { IMoniker } from 'core/naming/IMoniker'; export interface ILoadBalancerSourceData { cloudProvider?: string; @@ -20,6 +21,7 @@ export interface ILoadBalancer extends ITaggedEntity { listenerDescriptions?: any[]; loadBalancerType?: string; name?: string; + moniker?: IMoniker; provider?: string; region?: string; searchField?: string; diff --git a/app/scripts/modules/core/src/loadBalancer/loadBalancer.write.service.ts b/app/scripts/modules/core/src/loadBalancer/loadBalancer.write.service.ts index e436d5c66bd..b90844f29a3 100644 --- a/app/scripts/modules/core/src/loadBalancer/loadBalancer.write.service.ts +++ b/app/scripts/modules/core/src/loadBalancer/loadBalancer.write.service.ts @@ -4,6 +4,7 @@ import { Application } from 'core/application/application.model'; import { INFRASTRUCTURE_CACHE_SERVICE, InfrastructureCacheService } from 'core/cache/infrastructureCaches.service'; import { ITask } from 'core/domain'; import { IJob, TASK_EXECUTOR, TaskExecutor } from 'core/task/taskExecutor'; +import { IMoniker } from 'core/naming/IMoniker'; export interface ILoadBalancerUpsertCommand extends IJob { name: string; @@ -14,6 +15,7 @@ export interface ILoadBalancerUpsertCommand extends IJob { healthCheck?: string; healthCheckPort?: number; healthCheckPath?: string; + moniker?: IMoniker; region: string; stack?: string; }