forked from spinnaker/deck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gcb): add Google Cloud Build stage (spinnaker#6774)
* refactor(core): move yamlEditor from kubernetes to core module * feat(gcb): add Google Cloud Build stage
- Loading branch information
1 parent
98ea524
commit 50b74f2
Showing
13 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../modules/core/src/pipeline/config/stages/googleCloudBuild/GoogleCloudBuildStageConfig.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import * as React from 'react'; | ||
import Select, { Option } from 'react-select'; | ||
|
||
import { IgorService, IStageConfigProps, StageConfigField, YamlEditor, yamlDocumentsToString } from '@spinnaker/core'; | ||
|
||
export interface IGoogleCloudBuildStageConfigState { | ||
googleCloudBuildAccounts: string[]; | ||
rawBuildDefinitionYaml: string; | ||
} | ||
|
||
export class GoogleCloudBuildStageConfig extends React.Component<IStageConfigProps, IGoogleCloudBuildStageConfigState> { | ||
public constructor(props: IStageConfigProps) { | ||
super(props); | ||
this.state = { | ||
googleCloudBuildAccounts: [], | ||
rawBuildDefinitionYaml: props.stage.buildDefinition ? yamlDocumentsToString([props.stage.buildDefinition]) : '', | ||
}; | ||
} | ||
|
||
public componentDidMount = (): void => { | ||
if (this.props.stage.isNew) { | ||
this.props.updateStageField({ application: this.props.application.name }); | ||
} | ||
this.fetchGoogleCloudBuildAccounts(); | ||
}; | ||
|
||
private onYamlChange = (rawYaml: string, yamlDocs: any): void => { | ||
this.setState({ rawBuildDefinitionYaml: rawYaml }); | ||
const buildDefinition = Array.isArray(yamlDocs) && yamlDocs.length > 0 ? yamlDocs[0] : null; | ||
this.props.updateStageField({ buildDefinition }); | ||
}; | ||
|
||
private onAccountChange = (accountOption: Option) => { | ||
this.props.updateStageField({ account: accountOption.value }); | ||
}; | ||
|
||
private getAccountOptions = (): Option[] => { | ||
return this.state.googleCloudBuildAccounts.map(account => ({ | ||
label: account, | ||
value: account, | ||
})); | ||
}; | ||
|
||
private fetchGoogleCloudBuildAccounts = () => { | ||
IgorService.getGcbAccounts().then((googleCloudBuildAccounts: string[]) => { | ||
this.setState({ | ||
googleCloudBuildAccounts, | ||
}); | ||
}); | ||
}; | ||
|
||
public render() { | ||
return ( | ||
<div> | ||
<StageConfigField label="Account"> | ||
<Select | ||
clearable={false} | ||
onChange={this.onAccountChange} | ||
options={this.getAccountOptions()} | ||
value={this.props.stage.account} | ||
/> | ||
</StageConfigField> | ||
<StageConfigField label="Build Config"> | ||
<YamlEditor value={this.state.rawBuildDefinitionYaml} onChange={this.onYamlChange} /> | ||
</StageConfigField> | ||
</div> | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...scripts/modules/core/src/pipeline/config/stages/googleCloudBuild/googleCloudBuildStage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ExecutionArtifactTab } from 'core/artifact'; | ||
import { ExecutionDetailsTasks } from 'core/pipeline'; | ||
import { Registry } from 'core/registry'; | ||
|
||
import { GoogleCloudBuildStageConfig } from './GoogleCloudBuildStageConfig'; | ||
|
||
Registry.pipeline.registerStage({ | ||
label: 'Google Cloud Build', | ||
description: 'Trigger a build in GCB (Google Cloud Build)', | ||
key: 'googleCloudBuild', | ||
producesArtifacts: true, | ||
component: GoogleCloudBuildStageConfig, | ||
executionDetailsSections: [ExecutionDetailsTasks, ExecutionArtifactTab], | ||
validators: [{ type: 'requiredField', fieldName: 'account' }], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './yamlEditor.component'; | ||
export * from './yamlEditorUtils'; | ||
export * from './YamlEditor'; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ifest/editor/yaml/yamlEditorUtils.spec.ts → ...re/src/yamlEditor/yamlEditorUtils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters