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(provider/google): Added cloudrun provider functionality in Deck. #9881

Closed
Closed
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
8 changes: 8 additions & 0 deletions halconfig/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ var appengine = {
account: '{%appengine.default.account%}',
},
};

var cloudrun = {
defaults: {
account: '{%cloudrun.default.account%}',
},
};

var oracle = {
defaults: {
account: '{%oracle.default.account%}',
Expand Down Expand Up @@ -147,6 +154,7 @@ window.spinnakerSettings = {
gce: gce,
huaweicloud: huaweicloud,
kubernetes: {},
cloudrun: cloudrun,
oracle: oracle,
tencentcloud: tencentcloud,
},
Expand Down
3 changes: 3 additions & 0 deletions karma-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ testContext.keys().forEach(testContext);

testContext = require.context('./packages/titus/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);
2 changes: 2 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const webpackConfig = {
'@spinnaker/tencentcloud': path.resolve(`${MODULES_ROOT}/tencentcloud/src`),
titus: path.resolve(`${MODULES_ROOT}/titus/src`),
'@spinnaker/titus': path.resolve(`${MODULES_ROOT}/titus/src`),
cloudrun: path.resolve(`${MODULES_ROOT}/cloudrun/src`),
'@spinnaker/cloudrun': path.resolve(`${MODULES_ROOT}/cloudrun/src`),
},
},
plugins: [new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true })],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"workspaces": [
"packages/app",
"packages/amazon",
"packages/cloudrun",
"packages/appengine",
"packages/azure",
"packages/cloudfoundry",
Expand Down
3 changes: 2 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@spinnaker/oracle": "^0.0.80",
"@spinnaker/styleguide": "^2.0.0",
"@spinnaker/titus": "^0.5.32",
"@spinnaker/cloudrun": "^0.0.1",
"@uirouter/angularjs": "1.0.26",
"angular": "1.8.0",
"graphql": "15.5.0",
Expand Down Expand Up @@ -81,4 +82,4 @@
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.0"
}
}
}
2 changes: 2 additions & 0 deletions packages/app/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AZURE_MODULE } from '@spinnaker/azure';
import { GOOGLE_MODULE } from '@spinnaker/google';
import { CANARY_MODULE } from './canary/canary.module';
import { KUBERNETES_MODULE } from '@spinnaker/kubernetes';
import { CLOUDRUN_MODULE } from '@spinnaker/cloudrun';
import { ORACLE_MODULE } from '@spinnaker/oracle';
import { KAYENTA_MODULE } from '@spinnaker/kayenta';
import { TITUS_MODULE } from '@spinnaker/titus';
Expand All @@ -23,6 +24,7 @@ module('netflix.spinnaker', [
AZURE_MODULE,
GOOGLE_MODULE,
ECS_MODULE,
CLOUDRUN_MODULE,
DOCKER_MODULE,
ORACLE_MODULE,
APPENGINE_MODULE,
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ window.spinnakerSettings = {
'gce',
'huaweicloud',
'kubernetes',
'cloudrun',
'oracle',
'tencentcloud',
],
Expand Down Expand Up @@ -174,6 +175,12 @@ window.spinnakerSettings = {
account: 'my-appengine-account',
},
},

cloudrun: {
defaults: {
account: 'my-cloudrun-account',
},
},
aws: {
defaults: {
account: 'test',
Expand Down Expand Up @@ -250,6 +257,7 @@ window.spinnakerSettings = {
},
},
kubernetes: {},

oracle: {
defaults: {
account: 'DEFAULT',
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.19.4",
"@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.0.17",
"enzyme": "3.10.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.2.5",
"@types/angular": "1.6.26",
"@types/angular-ui-bootstrap": "0.13.41",
"@types/dompurify": "0.0.29",
"@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"
}
}
73 changes: 73 additions & 0 deletions packages/cloudrun/src/cloudrun.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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',
//adHocInfrastructureWritesEnabled: SETTINGS.cloudrunAdHocInfraWritesEnabled,
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 = 'Cloudrun 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';
16 changes: 16 additions & 0 deletions packages/cloudrun/src/common/loadBalancerMessage.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<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 Cloudrun.</span>
A Spinnaker load balancer maps to an Cloudrun service, which along with a Revision are created from Create
Server Group page using a yaml file.
</p>

<p>
If a service does not exist when a version is deployed, it will be created. It will then be editable as a load
balancer within Spinnaker.
</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