Skip to content

Commit

Permalink
fix(provider/cf): fix deploy stage configuration from existing server…
Browse files Browse the repository at this point in the history
… group
  • Loading branch information
jmelchio authored and jkschneider committed Oct 24, 2018
1 parent cbb1327 commit 4db9789
Showing 1 changed file with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ import { IPromise, IQService, module } from 'angular';

import { IStage, IPipeline } from '@spinnaker/core';

import { ICloudFoundryApplication, ICloudFoundryServerGroup } from 'cloudfoundry/domain';
import { ICloudFoundryApplication, ICloudFoundryEnvVar, ICloudFoundryServerGroup } from 'cloudfoundry/domain';
import {
ICloudFoundryCreateServerGroupCommand,
ICloudFoundryDeployConfiguration,
} from './serverGroupConfigurationModel.cf';

export class CloudFoundryServerGroupCommandBuilder {
constructor(private $q: IQService) {
'ngInject';
public static buildUpdateServerGroupCommand(_originalServerGroup: any) {
throw new Error('Implement me!');
}

private static envVarsFromObject(someObject: any): ICloudFoundryEnvVar[] {
const envVars = [];
for (const property in someObject) {
if (someObject.hasOwnProperty(property)) {
const envVar = { key: property, value: someObject[property] };
envVars.push(envVar);
}
}
return envVars;
}

private getSubmitButtonLabel(mode: string) {
private static getSubmitButtonLabel(mode: string) {
switch (mode) {
case 'createPipeline':
return 'Add';
Expand All @@ -26,6 +37,10 @@ export class CloudFoundryServerGroupCommandBuilder {
}
}

constructor(private $q: IQService) {
'ngInject';
}

public buildNewServerGroupCommand(
app: ICloudFoundryApplication,
defaults: any,
Expand All @@ -40,7 +55,7 @@ export class CloudFoundryServerGroupCommandBuilder {
credentials: '',
viewState: {
mode: defaults.mode || 'create',
submitButtonLabel: this.getSubmitButtonLabel(defaults.mode || 'create'),
submitButtonLabel: CloudFoundryServerGroupCommandBuilder.getSubmitButtonLabel(defaults.mode || 'create'),
},
artifact: {
type: 'artifact',
Expand Down Expand Up @@ -70,12 +85,15 @@ export class CloudFoundryServerGroupCommandBuilder {
};
command.manifest = {
type: 'direct',
memory: serverGroup.memory + 'M',
diskQuota: serverGroup.diskQuota + 'M',
buildpack: serverGroup.droplet.buildpacks.length > 0 ? serverGroup.droplet.buildpacks[0].name : '',
instances: serverGroup.instances.length,
memory: serverGroup.memory ? serverGroup.memory + 'M' : '1024M',
diskQuota: serverGroup.diskQuota ? serverGroup.diskQuota + 'M' : '1024M',
buildpack:
serverGroup.droplet && serverGroup.droplet.buildpacks.length > 0
? serverGroup.droplet.buildpacks[0].name
: '',
instances: serverGroup.instances ? serverGroup.instances.length : 1,
routes: serverGroup.loadBalancers,
environment: [],
environment: CloudFoundryServerGroupCommandBuilder.envVarsFromObject(serverGroup.env),
services: (serverGroup.serviceInstances || []).map(serviceInstance => serviceInstance.name),
reference: '',
account: '',
Expand Down Expand Up @@ -122,10 +140,6 @@ export class CloudFoundryServerGroupCommandBuilder {
return app;
});
}

public buildUpdateServerGroupCommand(_originalServerGroup: any) {
throw new Error('Implement me!');
}
}

export const CLOUD_FOUNDRY_SERVER_GROUP_COMMAND_BUILDER = 'spinnaker.cloudfoundry.serverGroupCommandBuilder.service';
Expand Down

0 comments on commit 4db9789

Please sign in to comment.