-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added secret controller for fixes (#11488)
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
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
69 changes: 69 additions & 0 deletions
69
packages/deployment-service/src/pipeline-runner/secret.pipeline.controller.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,69 @@ | ||
import { Controller, Get, Inject, NotFoundException, Param, Post, forwardRef } from '@nestjs/common' | ||
import { PipelineProvider } from '../pipeline/pipeline-provider' | ||
import { EventDispatcher } from '../events' | ||
import { PipelineRunnerProvider } from './pipeline-runner-provider' | ||
|
||
@Controller('secret') | ||
export class SecretPipelineController { | ||
constructor( | ||
@Inject(forwardRef(() => PipelineProvider)) private readonly pipelineProvider: PipelineProvider, | ||
private readonly eventDispatcher: EventDispatcher, | ||
private readonly pipelineRunnerProvider: PipelineRunnerProvider, | ||
) {} | ||
|
||
@Get('developerId/:developerId') | ||
async findByDeveloper(@Param('developerId') developerId: string) { | ||
const pipelines = await this.pipelineProvider.findByDeveloperId(developerId) | ||
|
||
return pipelines | ||
} | ||
|
||
@Get('subdomain/:subdomain') | ||
async findBySubdomain(@Param('subdomain') subdomain: string) { | ||
const pipeline = await this.pipelineProvider.findBySubDomain(subdomain) | ||
|
||
if (!pipeline) throw NotFoundException | ||
|
||
return pipeline | ||
} | ||
|
||
// app / pipelineid | ||
@Get(':pipelineId') | ||
async findById(@Param('pipelineId') pipelineId: string) { | ||
const pipeline = await this.pipelineProvider.findById(pipelineId) | ||
|
||
if (!pipeline) throw NotFoundException | ||
|
||
return pipeline | ||
} | ||
|
||
@Post('provision/:pipelineId') | ||
async startProvisioning(@Param('pipelineId') pipelineId: string) { | ||
const pipeline = await this.pipelineProvider.findById(pipelineId) | ||
|
||
if (!pipeline) throw new NotFoundException() | ||
|
||
const updatedPipeline = await this.pipelineProvider.update(pipeline, { | ||
buildStatus: 'PROVISION_REQUEST', | ||
}) | ||
|
||
await this.eventDispatcher.triggerPipelineSetup(updatedPipeline) | ||
|
||
return updatedPipeline | ||
} | ||
|
||
@Post('deploy/:pipelineId') | ||
async startDeployment(@Param('pipelineId') pipelineId: string) { | ||
const pipeline = await this.pipelineProvider.findById(pipelineId) | ||
|
||
if (!pipeline) throw new NotFoundException() | ||
|
||
const pipelineRunner = await this.pipelineRunnerProvider.create({ | ||
pipeline, | ||
}) | ||
|
||
await this.eventDispatcher.triggerCodebuildExecutor(pipelineRunner) | ||
|
||
return pipelineRunner | ||
} | ||
} |
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