1
+ import * as codecommit from '@aws-cdk/aws-codecommit' ;
1
2
import * as ec2 from '@aws-cdk/aws-ec2' ;
2
3
import * as cdk from '@aws-cdk/core' ;
3
4
import { CfnEnvironmentEC2 } from '../lib/cloud9.generated' ;
@@ -20,7 +21,6 @@ export interface IEc2Environment extends cdk.IResource {
20
21
* @attribute environmentE2Arn
21
22
*/
22
23
readonly ec2EnvironmentArn : string ;
23
-
24
24
}
25
25
26
26
/**
@@ -67,38 +67,21 @@ export interface Ec2EnvironmentProps {
67
67
*
68
68
* @default - do not clone any repository
69
69
*/
70
- readonly clonedRepositories ?: Cloud9Repository [ ] ;
70
+ // readonly clonedRepositories?: Cloud9Repository[];
71
+ readonly clonedRepositories ?: CloneRepositoryConfig [ ] ;
71
72
}
72
73
73
74
/**
74
- * Repository provider
75
+ * The configuration for repository cloning
75
76
*/
76
- export enum Cloud9RepositoryProvider {
77
+ export interface CloneRepositoryConfig {
77
78
/**
78
- * AWS CodeCommit
79
+ * The URL of the git repository
79
80
*/
80
- AWS_CODECOMMIT
81
- }
81
+ readonly repositoryUrl : string ;
82
82
83
- /**
84
- * The interface of the codecommit repository for Cloud9 environment
85
- */
86
- export interface Cloud9Repository {
87
83
/**
88
- * Repository provider
89
- * @default AWS_CODECOMMIT
90
- */
91
- readonly provider ?: Cloud9RepositoryProvider ;
92
-
93
- /**
94
- * Repository URL
95
- */
96
- readonly url : string ;
97
-
98
- /**
99
- * The path within the development environment's default file system location to clone the AWS CodeCommit
100
- * repository into. For example, `/REPOSITORY_NAME` would clone the repository into the
101
- * `/home/USER_NAME/environment/REPOSITORY_NAME` directory in the environment.
84
+ * The target path of the cloud9 environment to clone the repository to
102
85
*/
103
86
readonly clonePath : string ;
104
87
}
@@ -167,7 +150,7 @@ export class Ec2Environment extends cdk.Resource implements IEc2Environment {
167
150
instanceType : props . instanceType ?. toString ( ) ?? ec2 . InstanceType . of ( ec2 . InstanceClass . BURSTABLE2 , ec2 . InstanceSize . MICRO ) . toString ( ) ,
168
151
subnetId : this . vpc . selectSubnets ( vpcSubnets ) . subnetIds [ 0 ] ,
169
152
repositories : props . clonedRepositories ? props . clonedRepositories . map ( r => ( {
170
- repositoryUrl : r . url ,
153
+ repositoryUrl : r . repositoryUrl ,
171
154
pathComponent : r . clonePath ,
172
155
} ) ) : undefined ,
173
156
} ) ;
@@ -177,3 +160,18 @@ export class Ec2Environment extends cdk.Resource implements IEc2Environment {
177
160
this . ideUrl = `https://${ this . stack . region } .console.aws.amazon.com/cloud9/ide/${ this . environmentId } ` ;
178
161
}
179
162
}
163
+
164
+ /**
165
+ * The class with static methods generating `CloneRepositoryConfig` for different repository providers
166
+ */
167
+ export class CloneRepository {
168
+ /**
169
+ * import repository to cloud9 environment from AWS CodeCommit
170
+ */
171
+ public static fromCodeCommit ( repository : codecommit . IRepository , path : string ) : CloneRepositoryConfig {
172
+ return {
173
+ repositoryUrl : repository . repositoryCloneUrlHttp ,
174
+ clonePath : path ,
175
+ } ;
176
+ }
177
+ }
0 commit comments