-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
metadata-schema.ts
325 lines (285 loc) · 7.88 KB
/
metadata-schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/**
* Common properties for asset metadata.
*/
interface BaseAssetMetadataEntry {
/**
* Requested packaging style
*/
readonly packaging: string;
/**
* Logical identifier for the asset
*/
readonly id: string;
/**
* The hash of the asset source.
*/
readonly sourceHash: string;
/**
* Path on disk to the asset
*/
readonly path: string;
}
/**
* Metadata Entry spec for files.
*
* @example
* const entry = {
* packaging: 'file',
* s3BucketParameter: 'bucket-parameter',
* s3KeyParamenter: 'key-parameter',
* artifactHashParameter: 'hash-parameter',
* }
*/
export interface FileAssetMetadataEntry extends BaseAssetMetadataEntry {
/**
* Requested packaging style
*/
readonly packaging: 'zip' | 'file';
/**
* Name of parameter where S3 bucket should be passed in
*/
readonly s3BucketParameter: string;
/**
* Name of parameter where S3 key should be passed in
*/
readonly s3KeyParameter: string;
/**
* The name of the parameter where the hash of the bundled asset should be passed in.
*/
readonly artifactHashParameter: string;
}
/**
* Metadata Entry spec for stack tag.
*/
export interface Tag {
/**
* Tag key.
*
* (In the actual file on disk this will be cased as "Key", and the structure is
* patched to match this structure upon loading:
* https://github.com/aws/aws-cdk/blob/4aadaa779b48f35838cccd4e25107b2338f05547/packages/%40aws-cdk/cloud-assembly-schema/lib/manifest.ts#L137)
*/
readonly key: string;
/**
* Tag value.
*
* (In the actual file on disk this will be cased as "Value", and the structure is
* patched to match this structure upon loading:
* https://github.com/aws/aws-cdk/blob/4aadaa779b48f35838cccd4e25107b2338f05547/packages/%40aws-cdk/cloud-assembly-schema/lib/manifest.ts#L137)
*/
readonly value: string;
}
/**
* Options for configuring the Docker cache backend
*/
export interface ContainerImageAssetCacheOption {
/**
* The type of cache to use.
* Refer to https://docs.docker.com/build/cache/backends/ for full list of backends.
* @default - unspecified
*
* @example 'registry'
*/
readonly type: string;
/**
* Any parameters to pass into the docker cache backend configuration.
* Refer to https://docs.docker.com/build/cache/backends/ for cache backend configuration.
* @default {} No options provided
*
* @example
* declare const branch: string;
*
* const params = {
* ref: `12345678.dkr.ecr.us-west-2.amazonaws.com/cache:${branch}`,
* mode: "max",
* };
*/
readonly params?: { [key: string]: string };
}
/**
* Metadata Entry spec for container images.
*
* @example
* const entry = {
* packaging: 'container-image',
* repositoryName: 'repository-name',
* imageTag: 'tag',
* }
*/
export interface ContainerImageAssetMetadataEntry extends BaseAssetMetadataEntry {
/**
* Type of asset
*/
readonly packaging: 'container-image';
/**
* ECR Repository name and repo digest (separated by "@sha256:") where this
* image is stored.
*
* @default undefined If not specified, `repositoryName` and `imageTag` are
* required because otherwise how will the stack know where to find the asset,
* ha?
* @deprecated specify `repositoryName` and `imageTag` instead, and then you
* know where the image will go.
*/
readonly imageNameParameter?: string;
/**
* ECR repository name, if omitted a default name based on the asset's ID is
* used instead. Specify this property if you need to statically address the
* image, e.g. from a Kubernetes Pod. Note, this is only the repository name,
* without the registry and the tag parts.
*
* @default - this parameter is REQUIRED after 1.21.0
*/
readonly repositoryName?: string;
/**
* The docker image tag to use for tagging pushed images. This field is
* required if `imageParameterName` is ommited (otherwise, the app won't be
* able to find the image).
*
* @default - this parameter is REQUIRED after 1.21.0
*/
readonly imageTag?: string;
/**
* Build args to pass to the `docker build` command
*
* @default no build args are passed
*/
readonly buildArgs?: { [key: string]: string };
/**
* SSH agent socket or keys to pass to the `docker build` command
*
* @default no ssh arg is passed
*/
readonly buildSsh?: string;
/**
* Build secrets to pass to the `docker build` command
*
* @default no build secrets are passed
*/
readonly buildSecrets?: { [key: string]: string };
/**
* Docker target to build to
*
* @default no build target
*/
readonly target?: string;
/**
* Path to the Dockerfile (relative to the directory).
*
* @default - no file is passed
*/
readonly file?: string;
/**
* Networking mode for the RUN commands during build.
*
* @default - no networking mode specified
*/
readonly networkMode?: string;
/**
* Platform to build for. _Requires Docker Buildx_.
*
* @default - current machine platform
*/
readonly platform?: string;
/**
* Outputs to pass to the `docker build` command.
*
* @default - no outputs are passed to the build command (default outputs are used)
* @see https://docs.docker.com/engine/reference/commandline/build/#custom-build-outputs
*/
readonly outputs?: string[];
/**
* Cache from options to pass to the `docker build` command.
*
* @default - no cache from options are passed to the build command
* @see https://docs.docker.com/build/cache/backends/
*/
readonly cacheFrom?: ContainerImageAssetCacheOption[];
/**
* Cache to options to pass to the `docker build` command.
*
* @default - no cache to options are passed to the build command
* @see https://docs.docker.com/build/cache/backends/
*/
readonly cacheTo?: ContainerImageAssetCacheOption;
/**
* Disable the cache and pass `--no-cache` to the `docker build` command.
*
* @default - cache is used
*/
readonly cacheDisabled?: boolean;
}
/**
* @see ArtifactMetadataEntryType.ASSET
*/
export type AssetMetadataEntry = FileAssetMetadataEntry | ContainerImageAssetMetadataEntry;
// Type aliases for metadata entries.
// Used simply to assign names to data types for more clarity.
/**
* @see ArtifactMetadataEntryType.INFO
* @see ArtifactMetadataEntryType.WARN
* @see ArtifactMetadataEntryType.ERROR
*/
export type LogMessageMetadataEntry = string;
/**
* @see ArtifactMetadataEntryType.LOGICAL_ID
*/
export type LogicalIdMetadataEntry = string;
/**
* @see ArtifactMetadataEntryType.STACK_TAGS
*/
export type StackTagsMetadataEntry = Tag[];
/**
* Union type for all metadata entries that might exist in the manifest.
*/
export type MetadataEntryData = AssetMetadataEntry | LogMessageMetadataEntry | LogicalIdMetadataEntry | StackTagsMetadataEntry;
/**
* Type of artifact metadata entry.
*/
export enum ArtifactMetadataEntryType {
/**
* Asset in metadata.
*/
ASSET = 'aws:cdk:asset',
/**
* Metadata key used to print INFO-level messages by the toolkit when an app is syntheized.
*/
INFO = 'aws:cdk:info',
/**
* Metadata key used to print WARNING-level messages by the toolkit when an app is syntheized.
*/
WARN = 'aws:cdk:warning',
/**
* Metadata key used to print ERROR-level messages by the toolkit when an app is syntheized.
*/
ERROR = 'aws:cdk:error',
/**
* Represents the CloudFormation logical ID of a resource at a certain path.
*/
LOGICAL_ID = 'aws:cdk:logicalId',
/**
* Represents tags of a stack.
*/
STACK_TAGS = 'aws:cdk:stack-tags',
}
/**
* A metadata entry in a cloud assembly artifact.
*/
export interface MetadataEntry {
/**
* The type of the metadata entry.
*/
readonly type: string;
/**
* The data.
*
* @default - no data.
*/
readonly data?: MetadataEntryData;
/**
* A stack trace for when the entry was created.
*
* @default - no trace.
*/
readonly trace?: string[];
}