Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(moniker) - adding monikers to load balancers #4278

Merged
merged 1 commit into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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