Skip to content

Commit

Permalink
feat(provider/cloudrun): Added cloudrun functionality to deck (#9931)
Browse files Browse the repository at this point in the history
* feat(provider/cloudrun): Added cloudrun functionality to deck

* feat(provider/cloudrun): Incorporated Suggested Changes

* feat(provider/cloudRun): Fixed build issue

---------

Co-authored-by: rsinghsidhu <[email protected]>
  • Loading branch information
siddhu-opsmx and rajinderSiddhu authored Mar 10, 2023
1 parent 306c5f9 commit 3611e95
Show file tree
Hide file tree
Showing 59 changed files with 2,707 additions and 1 deletion.
6 changes: 6 additions & 0 deletions halconfig/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ var cloudfoundry = {
account: '{%cloudfoundry.default.account%}',
},
};
var cloudrun = {
defaults: {
account: '{%cloudrun.default.account%}',
},
};
var dcos = {
defaults: {
account: '{%dcos.default.account%}',
Expand Down Expand Up @@ -145,6 +150,7 @@ window.spinnakerSettings = {
aws: aws,
azure: azure,
cloudfoundry: cloudfoundry,
cloudrun: cloudrun,
dcos: dcos,
ecs: ecs,
gce: gce,
Expand Down
3 changes: 3 additions & 0 deletions karma-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ testContext.keys().forEach(testContext);
testContext = require.context('./packages/cloudfoundry/src', true, /\.spec\.(js|ts|tsx)$/);
testContext.keys().forEach(testContext);

testContext = require.context('./packages/cloudrun/src', true, /\.spec\.(js|ts|tsx)$/);
testContext.keys().forEach(testContext);

testContext = require.context('./packages/core/src', true, /\.spec\.(js|ts|tsx)$/);
testContext.keys().forEach(testContext);

Expand Down
2 changes: 2 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const webpackConfig = {
'@spinnaker/azure': path.resolve(`${MODULES_ROOT}/azure/src`),
cloudfoundry: path.resolve(`${MODULES_ROOT}/cloudfoundry/src`),
'@spinnaker/cloudfoundry': path.resolve(`${MODULES_ROOT}/cloudfoundry/src`),
cloudrun: path.resolve(`${MODULES_ROOT}/cloudrun/src`),
'@spinnaker/cloudrun': path.resolve(`${MODULES_ROOT}/cloudrun/src`),
core: path.resolve(`${MODULES_ROOT}/core/src`),
'@spinnaker/core': path.resolve(`${MODULES_ROOT}/core/src`),
dcos: path.resolve(`${MODULES_ROOT}/dcos/src`),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"packages/appengine",
"packages/azure",
"packages/cloudfoundry",
"packages/cloudrun",
"packages/core",
"packages/dcos",
"packages/docker",
Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@spinnaker/amazon": "^0.13.5",
"@spinnaker/appengine": "^0.1.3",
"@spinnaker/cloudfoundry": "^0.1.3",
"@spinnaker/cloudrun": "^0.0.1",
"@spinnaker/core": "^0.23.0",
"@spinnaker/docker": "^0.0.137",
"@spinnaker/ecs": "^0.0.356",
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ORACLE_MODULE } from '@spinnaker/oracle';
import { KAYENTA_MODULE } from '@spinnaker/kayenta';
import { TITUS_MODULE } from '@spinnaker/titus';
import { ECS_MODULE } from '@spinnaker/ecs';
import { CLOUDRUN_MODULE } from '@spinnaker/cloudrun';
import '@spinnaker/cloudfoundry';

module('netflix.spinnaker', [
Expand All @@ -30,4 +31,5 @@ module('netflix.spinnaker', [
KUBERNETES_MODULE,
KAYENTA_MODULE,
TITUS_MODULE,
CLOUDRUN_MODULE,
]);
6 changes: 6 additions & 0 deletions packages/app/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ window.spinnakerSettings = {
'aws',
'azure',
'cloudfoundry',
'cloudrun',
'dcos',
'ecs',
'gce',
Expand Down Expand Up @@ -211,6 +212,11 @@ window.spinnakerSettings = {
account: 'my-cloudfoundry-account',
},
},
cloudrun: {
defaults: {
account: 'my-cloudrun-account',
},
},
dcos: {
defaults: {
account: 'my-dcos-account',
Expand Down
4 changes: 4 additions & 0 deletions packages/cloudrun/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
yalc.*
.*
tsconfig.json
webpack.config.js
53 changes: 53 additions & 0 deletions packages/cloudrun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@spinnaker/cloudrun",
"license": "Apache-2.0",
"version": "0.0.1",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"clean": "shx rm -rf dist",
"prepublishOnly": "npm run build",
"build": "npm run clean && spinnaker-scripts build",
"dev": "spinnaker-scripts start",
"dev:push": "spinnaker-scripts start --push",
"lib": "npm run build"
},
"dependencies": {
"@spinnaker/core": "^0.23.0",
"@uirouter/angularjs": "1.0.26",
"@uirouter/react": "1.0.7",
"angular": "1.6.10",
"angular-ui-bootstrap": "2.5.0",
"brace": "0.11.1",
"dompurify": "^2.3.10",
"enzyme": "3.11.0",
"formik": "1.5.1",
"js-yaml": "3.13.1",
"lodash": "4.17.21",
"luxon": "1.23.0",
"ngimport": "0.6.1",
"react": "16.14.0",
"react-ace": "6.4.0",
"react-bootstrap": "0.32.1",
"react-ga": "2.4.1",
"react-select": "1.2.1",
"react2angular": "3.2.1",
"rxjs": "6.6.7"
},
"devDependencies": {
"@spinnaker/eslint-plugin": "^3.0.1",
"@spinnaker/scripts": "^0.3.0",
"@types/angular": "1.6.26",
"@types/angular-ui-bootstrap": "0.13.41",
"@types/dompurify": "^2.3.3",
"@types/enzyme": "3.10.3",
"@types/js-yaml": "3.5.30",
"@types/lodash": "4.14.64",
"@types/luxon": "1.11.1",
"@types/react": "16.14.10",
"@types/react-bootstrap": "0.32.5",
"@types/react-select": "1.3.4",
"shx": "0.3.3",
"typescript": "4.3.5"
}
}
72 changes: 72 additions & 0 deletions packages/cloudrun/src/cloudrun.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { module } from 'angular';

import { CloudProviderRegistry, DeploymentStrategyRegistry } from '@spinnaker/core';

import { CLOUDRUN_COMPONENT_URL_DETAILS } from './common/componentUrlDetails.component';
import { CLOUDRUN_LOAD_BALANCER_CREATE_MESSAGE } from './common/loadBalancerMessage.component';
import './help/cloudrun.help';
import { CLOUDRUN_INSTANCE_DETAILS_CTRL } from './instance/details/details.controller';
import { CLOUDRUN_ALLOCATION_CONFIGURATION_ROW } from './loadBalancer/configure/wizard/allocationConfigurationRow.component';
import { CLOUDRUN_LOAD_BALANCER_BASIC_SETTINGS } from './loadBalancer/configure/wizard/basicSettings.component';
import { CLOUDRUN_STAGE_ALLOCATION_CONFIGURATION_ROW } from './loadBalancer/configure/wizard/stageAllocationConfigurationRow.component';
import { CLOUDRUN_LOAD_BALANCER_WIZARD_CTRL } from './loadBalancer/configure/wizard/wizard.controller';
import { CLOUDRUN_LOAD_BALANCER_DETAILS_CTRL } from './loadBalancer/details/details.controller';
import { CLOUDRUN_LOAD_BALANCER_TRANSFORMER } from './loadBalancer/loadBalancerTransformer';
import logo from './logo/cloudrun.logo.png';
import { CLOUDRUN_PIPELINE_MODULE } from './pipeline/pipeline.module';
import { CLOUDRUN_SERVER_GROUP_COMMAND_BUILDER } from './serverGroup/configure/serverGroupCommandBuilder.service';
import { ServerGroupWizard } from './serverGroup/configure/wizard/serverGroupWizard';
import { CLOUDRUN_SERVER_GROUP_DETAILS_CTRL } from './serverGroup/details/details.controller';
import { CLOUDRUN_SERVER_GROUP_TRANSFORMER } from './serverGroup/serverGroupTransformer.service';

import './logo/cloudrun.logo.less';

export const CLOUDRUN_MODULE = 'spinnaker.cloudrun';

const requires = [
CLOUDRUN_COMPONENT_URL_DETAILS,
CLOUDRUN_SERVER_GROUP_COMMAND_BUILDER,
CLOUDRUN_SERVER_GROUP_DETAILS_CTRL,
CLOUDRUN_SERVER_GROUP_TRANSFORMER,
CLOUDRUN_LOAD_BALANCER_TRANSFORMER,
CLOUDRUN_LOAD_BALANCER_DETAILS_CTRL,
CLOUDRUN_LOAD_BALANCER_WIZARD_CTRL,
CLOUDRUN_LOAD_BALANCER_CREATE_MESSAGE,
CLOUDRUN_ALLOCATION_CONFIGURATION_ROW,
CLOUDRUN_LOAD_BALANCER_BASIC_SETTINGS,
CLOUDRUN_STAGE_ALLOCATION_CONFIGURATION_ROW,
CLOUDRUN_PIPELINE_MODULE,
CLOUDRUN_INSTANCE_DETAILS_CTRL,
];

module(CLOUDRUN_MODULE, requires).config(() => {
CloudProviderRegistry.registerProvider('cloudrun', {
name: 'cloudrun',
logo: {
path: logo,
},

instance: {
detailsTemplateUrl: require('./instance/details/details.html'),
detailsController: 'cloudrunInstanceDetailsCtrl',
},
serverGroup: {
CloneServerGroupModal: ServerGroupWizard,
commandBuilder: 'cloudrunV2ServerGroupCommandBuilder',
detailsController: 'cloudrunV2ServerGroupDetailsCtrl',
detailsTemplateUrl: require('./serverGroup/details/details.html'),
transformer: 'cloudrunV2ServerGroupTransformer',
skipUpstreamStageCheck: true,
},

loadBalancer: {
transformer: 'cloudrunLoadBalancerTransformer',
createLoadBalancerTemplateUrl: require('./loadBalancer/configure/wizard/wizard.html'),
createLoadBalancerController: 'cloudrunLoadBalancerWizardCtrl',
detailsTemplateUrl: require('./loadBalancer/details/details.html'),
detailsController: 'cloudrunLoadBalancerDetailsCtrl',
},
});
});

DeploymentStrategyRegistry.registerProvider('cloudrun', ['custom', 'redblack', 'rollingpush', 'rollingredblack']);
14 changes: 14 additions & 0 deletions packages/cloudrun/src/cloudrun.settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { IProviderSettings } from '@spinnaker/core';
import { SETTINGS } from '@spinnaker/core';

export interface ICloudrunProviderSettings extends IProviderSettings {
defaults: {
account?: string;
};
}

export const CloudrunProviderSettings: ICloudrunProviderSettings = (SETTINGS.providers
.cloudrun as ICloudrunProviderSettings) || { defaults: {} };
if (CloudrunProviderSettings) {
CloudrunProviderSettings.resetToOriginal = SETTINGS.resetProvider('cloudrun');
}
3 changes: 3 additions & 0 deletions packages/cloudrun/src/common/cloudrunHealth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class CloudrunHealth {
public static PLATFORM = 'Cloud Run Service';
}
22 changes: 22 additions & 0 deletions packages/cloudrun/src/common/componentUrlDetails.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { IComponentOptions } from 'angular';
import { module } from 'angular';

const cloudrunComponentUrlDetailsComponent: IComponentOptions = {
bindings: { component: '<' },
template: `
<dt>HTTPS</dt>
<dl class="small">
<a href="{{$ctrl.component.url}}" target="_blank">{{$ctrl.component.url}}</a>
<copy-to-clipboard class="copy-to-clipboard copy-to-clipboard-sm"
tool-tip="'Copy URL to clipboard'"
text="$ctrl.component.httpsUrl"></copy-to-clipboard>
</dl>
`,
};

export const CLOUDRUN_COMPONENT_URL_DETAILS = 'spinnaker.cloudrun.componentUrlDetails.component';

module(CLOUDRUN_COMPONENT_URL_DETAILS, []).component(
'cloudrunComponentUrlDetails',
cloudrunComponentUrlDetailsComponent,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { IComponentOptions, IController, IFilterService } from 'angular';
import { module } from 'angular';

class CloudrunConditionalDescriptionListItemCtrl implements IController {
public label: string;
public key: string;
public component: any;

public static $inject = ['$filter'];
constructor(private $filter: IFilterService) {}

public $onInit(): void {
if (!this.label) {
this.label = this.$filter<Function>('robotToHuman')(this.key);
}
}
}

const cloudrunConditionalDescriptionListItem: IComponentOptions = {
bindings: { label: '@', key: '@', component: '<' },
transclude: {
keyLabel: '?keyText',
valueLabel: '?valueLabel',
},
template: `
<dt ng-if="$ctrl.component[$ctrl.key]">{{$ctrl.label}}<span ng-transclude="keyLabel"></span></dt>
<dd ng-if="$ctrl.component[$ctrl.key]">{{$ctrl.component[$ctrl.key]}}<span ng-transclude="valueLabel"></span></dd>
`,
controller: CloudrunConditionalDescriptionListItemCtrl,
};

export const CLOUDRUN_CONDITIONAL_DESCRIPTION_LIST_ITEM = 'spinnaker.cloudrun.conditionalDescriptionListItem';

module(CLOUDRUN_CONDITIONAL_DESCRIPTION_LIST_ITEM, []).component(
'cloudrunConditionalDtDd',
cloudrunConditionalDescriptionListItem,
);
21 changes: 21 additions & 0 deletions packages/cloudrun/src/common/domain/ICloudrunInstance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { IInstance } from '@spinnaker/core';

export interface ICloudrunInstance extends IInstance {
name: string;
id: string;
account?: string;
region?: string;
instanceStatus: 'DYNAMIC' | 'RESIDENT' | 'UNKNOWN';
launchTime: number;
loadBalancers: string[];
serverGroup: string;
vmDebugEnabled: boolean;
vmName: string;
vmStatus: string;
vmZoneName: string;
qps: number;
healthState: string;
cloudProvider: string;
errors: number;
averageLatency: number;
}
18 changes: 18 additions & 0 deletions packages/cloudrun/src/common/domain/ICloudrunLoadBalancer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ILoadBalancer } from '@spinnaker/core';

export interface ICloudrunLoadBalancer extends ILoadBalancer {
credentials?: string;
split?: ICloudrunTrafficSplit;
migrateTraffic: boolean;
dispatchRules?: ICloudrunDispatchRule[];
}

export interface ICloudrunTrafficSplit {
trafficTargets: [{ revisionName: string; percent: number }];
}

export interface ICloudrunDispatchRule {
domain: string;
path: string;
service: string;
}
2 changes: 2 additions & 0 deletions packages/cloudrun/src/common/domain/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './ICloudrunLoadBalancer';
export * from './ICloudrunInstance';
11 changes: 11 additions & 0 deletions packages/cloudrun/src/common/loadBalancerMessage.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="row">
<div class="col-md-offset-{{ $ctrl.columnOffset || 0 }} col-md-{{ $ctrl.columns || 12 }}">
<div class="well">
<p>
<span ng-if="$ctrl.showCreateMessage">Spinnaker cannot create a load balancer for Cloud Run.</span>
A Spinnaker load balancer maps to an Cloud Run Service, which will be created automatically alongside a
Revision. Once created, the Service can be edited as a Load Balancer.
</p>
</div>
</div>
</div>
13 changes: 13 additions & 0 deletions packages/cloudrun/src/common/loadBalancerMessage.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { module } from 'angular';

const cloudRunLoadBalancerMessageComponent: ng.IComponentOptions = {
bindings: { showCreateMessage: '<', columnOffset: '@', columns: '@' },
templateUrl: require('./loadBalancerMessage.component.html'),
};

export const CLOUDRUN_LOAD_BALANCER_CREATE_MESSAGE = 'spinnaker.cloudrun.loadBalancer.createMessage.component';

module(CLOUDRUN_LOAD_BALANCER_CREATE_MESSAGE, []).component(
'cloudrunLoadBalancerMessage',
cloudRunLoadBalancerMessageComponent,
);
Loading

0 comments on commit 3611e95

Please sign in to comment.