UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 6.46 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CodePipelineSource=void 0;const jsiiDeprecationWarnings=require("../../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),cp_actions=require("../../../aws-codepipeline-actions"),core_1=require("../../../core"),constructs_1=require("constructs"),outputs_1=require("./private/outputs"),blueprint_1=require("../blueprint");class CodePipelineSource extends blueprint_1.Step{constructor(){super(...arguments),this.isSource=!0}static gitHub(repoString,branch,props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_pipelines_GitHubSourceOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.gitHub),error}return new GitHubSource(repoString,branch,props)}static s3(bucket,objectKey,props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_s3_IBucket(bucket),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_S3SourceOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.s3),error}return new S3Source(bucket,objectKey,props)}static ecr(repository,props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_ecr_IRepository(repository),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_ECRSourceOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.ecr),error}return new ECRSource(repository,props)}static connection(repoString,branch,props){try{jsiiDeprecationWarnings.aws_cdk_lib_pipelines_ConnectionSourceOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.connection),error}return new CodeStarConnectionSource(repoString,branch,props)}static codeCommit(repository,branch,props={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_codecommit_IRepository(repository),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_CodeCommitSourceOptions(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.codeCommit),error}return new CodeCommitSource(repository,branch,props)}produceAction(stage,options){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_codepipeline_IStage(stage),jsiiDeprecationWarnings.aws_cdk_lib_pipelines_ProduceActionOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.produceAction),error}const output=options.artifacts.toCodePipeline(this.primaryOutput),action=this.getAction(output,options.actionName,options.runOrder,options.variablesNamespace);return stage.addAction(action),{runOrdersConsumed:1}}sourceAttribute(name){return outputs_1.makeCodePipelineOutput(this,name)}}exports.CodePipelineSource=CodePipelineSource,_a=JSII_RTTI_SYMBOL_1,CodePipelineSource[_a]={fqn:"aws-cdk-lib.pipelines.CodePipelineSource",version:"2.70.0"};class GitHubSource extends CodePipelineSource{constructor(repoString,branch,props){super(repoString),this.branch=branch,this.props=props;const parts=repoString.split("/");if(core_1.Token.isUnresolved(repoString)||parts.length!==2)throw new Error(`GitHub repository name should be a resolved string like '<owner>/<repo>', got '${repoString}'`);this.owner=parts[0],this.repo=parts[1],this.authentication=props.authentication??core_1.SecretValue.secretsManager("github-token"),this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,actionName,runOrder,variablesNamespace){return new cp_actions.GitHubSourceAction({output,actionName:this.props.actionName??actionName,runOrder,oauthToken:this.authentication,owner:this.owner,repo:this.repo,branch:this.branch,trigger:this.props.trigger,variablesNamespace})}}class S3Source extends CodePipelineSource{constructor(bucket,objectKey,props){super(constructs_1.Node.of(bucket).addr),this.bucket=bucket,this.objectKey=objectKey,this.props=props,this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,_actionName,runOrder,variablesNamespace){return new cp_actions.S3SourceAction({output,actionName:this.props.actionName??this.bucket.bucketName,runOrder,bucketKey:this.objectKey,trigger:this.props.trigger,bucket:this.bucket,role:this.props.role,variablesNamespace})}}class ECRSource extends CodePipelineSource{constructor(repository,props){super(constructs_1.Node.of(repository).addr),this.repository=repository,this.props=props,this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,_actionName,runOrder,variablesNamespace){const formattedRepositoryName=core_1.Fn.join("_",core_1.Fn.split("/",this.repository.repositoryName));return new cp_actions.EcrSourceAction({output,actionName:this.props.actionName??formattedRepositoryName,runOrder,repository:this.repository,imageTag:this.props.imageTag,variablesNamespace})}}class CodeStarConnectionSource extends CodePipelineSource{constructor(repoString,branch,props){super(repoString),this.branch=branch,this.props=props;const parts=repoString.split("/");if(core_1.Token.isUnresolved(repoString)||parts.length!==2)throw new Error(`CodeStar repository name should be a resolved string like '<owner>/<repo>', got '${repoString}'`);this.owner=parts[0],this.repo=parts[1],this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,actionName,runOrder,variablesNamespace){return new cp_actions.CodeStarConnectionsSourceAction({output,actionName:this.props.actionName??actionName,runOrder,connectionArn:this.props.connectionArn,owner:this.owner,repo:this.repo,branch:this.branch,codeBuildCloneOutput:this.props.codeBuildCloneOutput,triggerOnPush:this.props.triggerOnPush,variablesNamespace})}}class CodeCommitSource extends CodePipelineSource{constructor(repository,branch,props){super(core_1.Token.isUnresolved(repository.repositoryName)?constructs_1.Node.of(repository).addr:repository.repositoryName),this.repository=repository,this.branch=branch,this.props=props,this.configurePrimaryOutput(new blueprint_1.FileSet("Source",this))}getAction(output,_actionName,runOrder,variablesNamespace){return new cp_actions.CodeCommitSourceAction({output,actionName:this.props.actionName??this.repository.repositoryName,runOrder,branch:this.branch,trigger:this.props.trigger,repository:this.repository,eventRole:this.props.eventRole,codeBuildCloneOutput:this.props.codeBuildCloneOutput,variablesNamespace})}}