Skip to content

Commit

Permalink
feat(cf): Remove React shims from pipeline stages (#6856)
Browse files Browse the repository at this point in the history
- Also repaired minor bug in Unshare Service
- Added Map / Unmap Load Balancer execution details

spinnaker/spinnaker#4284

Co-Authored-By: Joris Melchior <joris.melchior@gmail.com>
  • Loading branch information
2 people authored and jkschneider committed Apr 24, 2019
1 parent fee4c12 commit 33373c4
Show file tree
Hide file tree
Showing 33 changed files with 334 additions and 896 deletions.
17 changes: 6 additions & 11 deletions app/scripts/modules/cloudfoundry/src/cf.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ import { CloudFoundryNoLoadBalancerModal } from './loadBalancer/configure/cloudF
import 'cloudfoundry/pipeline/config/validation/cfTargetImpedance.validator';
import 'cloudfoundry/pipeline/config/validation/instanceSize.validator';
import 'cloudfoundry/pipeline/config/validation/requiredRoutes.validator';
import { CLOUD_FOUNDRY_CLONE_SERVER_GROUP_STAGE } from './pipeline/stages/cloneServerGroup/cloudfoundryCloneServerGroupStage.module';
import './pipeline/stages/cloneServerGroup/cloudfoundryCloneServerGroupStage.module';
import './pipeline/stages/createServiceKey/cloudfoundryCreateServiceKeyStage.module';
import './pipeline/stages/deployService/cloudfoundryDeployServiceStage.module';
import { CLOUD_FOUNDRY_DESTROY_ASG_STAGE } from './pipeline/stages/destroyAsg/cloudfoundryDestroyAsgStage.module';
import './pipeline/stages/destroyAsg/cloudfoundryDestroyAsgStage.module';
import './pipeline/stages/destroyService/cloudfoundryDestroyServiceStage.module';
import { CLOUD_FOUNDRY_DISABLE_ASG_STAGE } from './pipeline/stages/disableAsg/cloudfoundryDisableAsgStage.module';
import { CLOUD_FOUNDRY_ENABLE_ASG_STAGE } from './pipeline/stages/enableAsg/cloudfoundryEnableAsgStage.module';
import './pipeline/stages/disableAsg/cloudfoundryDisableAsgStage.module';
import './pipeline/stages/enableAsg/cloudfoundryEnableAsgStage.module';
import './pipeline/stages/mapLoadBalancers/cloudfoundryMapLoadBalancersStage.module';
import './pipeline/stages/unmapLoadBalancers/cloudfoundryUnmapLoadBalancersStage.module';
import { CLOUD_FOUNDRY_RESIZE_ASG_STAGE } from './pipeline/stages/resizeAsg/cloudfoundryResizeAsgStage.module';
import './pipeline/stages/resizeAsg/cloudfoundryResizeAsgStage.module';
import './pipeline/stages/rollbackCluster/cloudfoundryRollbackClusterStage.module';
import './pipeline/stages/shareService/cloudfoundryShareServiceStage.module';
import './pipeline/stages/unmapLoadBalancers/cloudfoundryUnmapLoadBalancersStage.module';
import './pipeline/stages/unshareService/cloudfoundryUnshareServiceStage.module';
import { CloudFoundryCreateServerGroupModal } from 'cloudfoundry/serverGroup/configure/wizard/CreateServerGroupModal';
import { CLOUD_FOUNDRY_INSTANCE_DETAILS } from 'cloudfoundry/instance/details/cloudfoundryInstanceDetails.module';
Expand All @@ -51,14 +51,9 @@ templates.keys().forEach(function(key) {

export const CLOUD_FOUNDRY_MODULE = 'spinnaker.cloudfoundry';
module(CLOUD_FOUNDRY_MODULE, [
CLOUD_FOUNDRY_CLONE_SERVER_GROUP_STAGE,
CLOUD_FOUNDRY_DESTROY_ASG_STAGE,
CLOUD_FOUNDRY_DISABLE_ASG_STAGE,
CLOUD_FOUNDRY_ENABLE_ASG_STAGE,
CLOUD_FOUNDRY_INSTANCE_DETAILS,
CLOUD_FOUNDRY_LOAD_BALANCER_MODULE,
CLOUD_FOUNDRY_REACT_MODULE,
CLOUD_FOUNDRY_RESIZE_ASG_STAGE,
CLOUD_FOUNDRY_SEARCH_FORMATTER,
CLOUD_FOUNDRY_SERVER_GROUP_COMMAND_BUILDER,
CLOUD_FOUNDRY_SERVER_GROUP_TRANSFORMER,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
import * as React from 'react';

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

import { CloudFoundryCreateServerGroupModal } from 'cloudfoundry/serverGroup/configure/wizard/CreateServerGroupModal';
import { CloudFoundryReactInjector } from 'cloudfoundry/reactShims';

export interface ICloudfoundryCloneServerGroupStageProps extends IStageConfigProps {
pipeline: IPipeline;
}

export interface ICloudfoundryCloneServerGroupStageConfigState {
buttonText: string;
}

export class CloudfoundryCloneServerGroupStageConfig extends React.Component<
ICloudfoundryCloneServerGroupStageProps,
IStageConfigProps,
ICloudfoundryCloneServerGroupStageConfigState
> {
constructor(props: ICloudfoundryCloneServerGroupStageProps) {
constructor(props: IStageConfigProps) {
super(props);
props.stage.cloudProvider = 'cloudfoundry';
props.stage.application = props.application.name;
this.props.updateStageField({
cloudProvider: 'cloudfoundry',
application: props.application.name,
});
this.state = {
buttonText: props.stage.destination ? 'Edit clone configuration' : 'Add clone configuration',
};
}

private handleResult = (command: any) => {
this.props.stage.credentials = command.credentials;
this.props.stage.capacity = command.capacity;
this.props.stage.account = command.account;
this.props.stage.destination = command.destination;
this.props.stage.delayBeforeDisableSec = command.delayBeforeDisableSec;
this.props.stage.freeFormDetails = command.freeFormDetails;
this.props.stage.maxRemainingAsgs = command.maxRemainingAsgs;
this.props.stage.region = command.region;
this.props.stage.startApplication = command.startApplication;
this.props.stage.stack = command.stack;
this.props.stage.strategy = command.strategy;
this.props.stage.target = command.target;
this.props.stage.targetCluster = command.targetCluster;
this.props.stage.manifest = command.manifest;
this.props.updateStageField({
credentials: command.credentials,
capacity: command.capacity,
account: command.account,
destination: command.destination,
delayBeforeDisableSec: command.delayBeforeDisableSec,
freeFormDetails: command.freeFormDetails,
maxRemainingAsgs: command.maxRemainingAsgs,
region: command.region,
startApplication: command.startApplication,
stack: command.stack,
strategy: command.strategy,
target: command.target,
targetCluster: command.targetCluster,
manifest: command.manifest,
});
this.setState({ buttonText: 'Edit clone configuration' });
this.props.stageFieldUpdated();
};

private addCluster = () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import { IController, IScope, module } from 'angular';
import { react2angular } from 'react2angular';
import { CloudfoundryCloneServerGroupStageConfig } from './CloudfoundryCloneServerGroupStageConfig';
import { IStage, Registry } from '@spinnaker/core';

class CloudfoundryCloneServerGroupStageCtrl implements IController {
public static $inject = ['$scope'];
constructor(public $scope: IScope) {}
}

export const CLOUD_FOUNDRY_CLONE_SERVER_GROUP_STAGE = 'spinnaker.cloudfoundry.pipeline.stage.cloneServerGroupStage';
module(CLOUD_FOUNDRY_CLONE_SERVER_GROUP_STAGE, [])
.config(function() {
Registry.pipeline.registerStage({
accountExtractor: (stage: IStage) => stage.context.credentials,
configAccountExtractor: (stage: IStage) => [stage.credentials],
provides: 'cloneServerGroup',
key: 'cloneServerGroup',
cloudProvider: 'cloudfoundry',
templateUrl: require('./cloudfoundryCloneServerGroupStage.html'),
controller: 'cfCloneServerGroupStageCtrl',
validators: [],
});
})
.component(
'cfCloneServerGroupStage',
react2angular(CloudfoundryCloneServerGroupStageConfig, ['application', 'pipeline', 'stage', 'stageFieldUpdated']),
)
.controller('cfCloneServerGroupStageCtrl', CloudfoundryCloneServerGroupStageCtrl);
Registry.pipeline.registerStage({
accountExtractor: (stage: IStage) => stage.context.credentials,
cloudProvider: 'cloudfoundry',
component: CloudfoundryCloneServerGroupStageConfig,
configAccountExtractor: (stage: IStage) => [stage.credentials],
key: 'cloneServerGroup',
provides: 'cloneServerGroup',
validators: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { CloudfoundryCreateServiceKeyExecutionDetails } from './CloudfoundryCrea

Registry.pipeline.registerStage({
accountExtractor: (stage: IStage) => stage.context.credentials,
configAccountExtractor: (stage: IStage) => [stage.credentials],
cloudProvider: 'cloudfoundry',
component: CloudfoundryCreateServiceKeyStageConfig,
configAccountExtractor: (stage: IStage) => [stage.credentials],
controller: 'BaseProviderStageCtrl as baseProviderStageCtrl',
description: 'Create a service key',
executionDetailsSections: [CloudfoundryCreateServiceKeyExecutionDetails, ExecutionDetailsTasks],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ PipelineConfigValidator.registerValidator(

Registry.pipeline.registerStage({
accountExtractor: (stage: IStage) => stage.context.credentials,
configAccountExtractor: (stage: IStage) => [stage.credentials],
label: 'Deploy Service',
description: 'Deploys services using Open Service Broker and deploys user-provided services',
key: 'deployService',
cloudProvider: 'cloudfoundry',
component: CloudfoundryDeployServiceStageConfig,
executionDetailsSections: [CloudfoundryServiceExecutionDetails, ExecutionDetailsTasks],
configAccountExtractor: (stage: IStage) => [stage.credentials],
defaultTimeoutMs: 30 * 60 * 1000,
description: 'Deploys services using Open Service Broker and deploys user-provided services',
executionDetailsSections: [CloudfoundryServiceExecutionDetails, ExecutionDetailsTasks],
key: 'deployService',
label: 'Deploy Service',
validators: [
{ type: 'requiredField', fieldName: 'credentials', fieldLabel: 'account' },
{ type: 'requiredField', fieldName: 'region' },
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
import { IController, IScope, module } from 'angular';
import { react2angular } from 'react2angular';
import { CloudfoundryAsgStageConfig } from 'cloudfoundry/presentation';
import { IStage, Registry } from '@spinnaker/core';

import { CloudfoundryDestroyAsgStageConfig } from './CloudfoundryDestroyAsgStageConfig';
import { Application, IStage, Registry } from '@spinnaker/core';

class CloudFoundryDestroyAsgStageCtrl implements IController {
public static $inject = ['$scope', 'application'];
constructor(public $scope: IScope, private application: Application) {
this.$scope.application = this.application;
}
}

export const CLOUD_FOUNDRY_DESTROY_ASG_STAGE = 'spinnaker.cloudfoundry.pipeline.stage.destroyAsgStage';
module(CLOUD_FOUNDRY_DESTROY_ASG_STAGE, [])
.config(function() {
Registry.pipeline.registerStage({
accountExtractor: (stage: IStage) => stage.context.credentials,
configAccountExtractor: (stage: IStage) => [stage.credentials],
provides: 'destroyServerGroup',
key: 'destroyServerGroup',
cloudProvider: 'cloudfoundry',
templateUrl: require('./cloudfoundryDestroyAsgStage.html'),
controller: 'cfDestroyAsgStageCtrl',
validators: [
{
type: 'cfTargetImpedance',
message:
'This pipeline will attempt to destroy a server group without deploying a new version into the same cluster.',
},
{ type: 'requiredField', fieldName: 'cluster' },
{ type: 'requiredField', fieldName: 'target' },
{ type: 'requiredField', fieldName: 'regions' },
{ type: 'requiredField', fieldName: 'credentials', fieldLabel: 'account' },
],
});
})
.component(
'cfDestroyAsgStage',
react2angular(CloudfoundryDestroyAsgStageConfig, ['application', 'pipeline', 'stage', 'stageFieldUpdated']),
)
.controller('cfDestroyAsgStageCtrl', CloudFoundryDestroyAsgStageCtrl);
Registry.pipeline.registerStage({
accountExtractor: (stage: IStage) => stage.context.credentials,
cloudProvider: 'cloudfoundry',
component: CloudfoundryAsgStageConfig,
configAccountExtractor: (stage: IStage) => [stage.credentials],
key: 'destroyServerGroup',
provides: 'destroyServerGroup',
validators: [
{
type: 'cfTargetImpedance',
message:
'This pipeline will attempt to destroy a server group without deploying a new version into the same cluster.',
},
{ type: 'requiredField', fieldName: 'cluster' },
{ type: 'requiredField', fieldName: 'target' },
{ type: 'requiredField', fieldName: 'regions' },
{ type: 'requiredField', fieldName: 'credentials', fieldLabel: 'account' },
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Registry.pipeline.registerStage({
configAccountExtractor: (stage: IStage) => [stage.credentials],
cloudProvider: 'cloudfoundry',
component: CloudfoundryDestroyServiceStageConfig,
controller: 'cfDestroyServiceStageCtrl',
defaultTimeoutMs: 30 * 60 * 1000,
executionDetailsSections: [CloudfoundryServiceExecutionDetails, ExecutionDetailsTasks],
key: 'destroyService',
Expand Down
Loading

0 comments on commit 33373c4

Please sign in to comment.