Skip to content

Commit

Permalink
feat(moniker) - adding monikers to load balancers (#4278)
Browse files Browse the repository at this point in the history
  • Loading branch information
imosquera authored and anotherchrisberry committed Oct 17, 2017
1 parent 375cf3e commit 9141d19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();
};

Expand Down Expand Up @@ -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(() => {
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/domain/ILoadBalancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +21,7 @@ export interface ILoadBalancer extends ITaggedEntity {
listenerDescriptions?: any[];
loadBalancerType?: string;
name?: string;
moniker?: IMoniker;
provider?: string;
region?: string;
searchField?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,6 +15,7 @@ export interface ILoadBalancerUpsertCommand extends IJob {
healthCheck?: string;
healthCheckPort?: number;
healthCheckPath?: string;
moniker?: IMoniker;
region: string;
stack?: string;
}
Expand Down

0 comments on commit 9141d19

Please sign in to comment.