Skip to content

Commit 0930fde

Browse files
committed
feat: add support for provenance option in docker build
1 parent 28dbd19 commit 0930fde

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/plugins/aws/provider.js

+12
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ class AwsProvider {
11341134
buildArgs: { type: 'object', additionalProperties: { type: 'string' } },
11351135
cacheFrom: { type: 'array', items: { type: 'string' } },
11361136
platform: { type: 'string' },
1137+
provenance: { type: 'string' },
11371138
},
11381139
additionalProperties: false,
11391140
},
@@ -2214,6 +2215,7 @@ Object.defineProperties(
22142215
buildArgs,
22152216
cacheFrom,
22162217
platform,
2218+
provenance,
22172219
scanOnPush,
22182220
}) {
22192221
const imageProgress = progress.get(`containerImage:${imageName}`);
@@ -2262,6 +2264,7 @@ Object.defineProperties(
22622264

22632265
// This is an optional argument, so we only append to the arguments if "platform" is specified.
22642266
if (platform !== '') buildDockerArgs.push(`--platform=${platform}`);
2267+
if (provenance !== '') buildDockerArgs.push(`--provenance=${provenance}`)
22652268

22662269
let imageSha;
22672270
try {
@@ -2396,6 +2399,7 @@ Object.defineProperties(
23962399
const defaultCacheFrom = [];
23972400
const defaultScanOnPush = false;
23982401
const defaultPlatform = '';
2402+
const defaultProvenance = ''
23992403

24002404
if (imageUri) {
24012405
return await this.resolveImageUriAndShaFromUri(imageUri);
@@ -2450,6 +2454,12 @@ Object.defineProperties(
24502454
'ECR_IMAGE_BOTH_URI_AND_PLATFORM_DEFINED_ERROR'
24512455
);
24522456
}
2457+
if (imageDefinedInProvider.uri && imageDefinedInProvider.provenance) {
2458+
throw new ServerlessError(
2459+
`The "provenance" property cannot be used with "uri" property "${imageName}"`,
2460+
'ECR_IMAGE_BOTH_URI_AND_PROVENANCE_DEFINED_ERROR',
2461+
)
2462+
}
24532463
if (imageDefinedInProvider.path) {
24542464
return await this.resolveImageUriAndShaFromPath({
24552465
imageName,
@@ -2458,6 +2468,7 @@ Object.defineProperties(
24582468
buildArgs: imageDefinedInProvider.buildArgs || defaultBuildArgs,
24592469
cacheFrom: imageDefinedInProvider.cacheFrom || defaultCacheFrom,
24602470
platform: imageDefinedInProvider.platform || defaultPlatform,
2471+
provenance: imageDefinedInProvider.provenance || defaultProvenance,
24612472
scanOnPush: imageScanDefinedInProvider,
24622473
});
24632474
}
@@ -2473,6 +2484,7 @@ Object.defineProperties(
24732484
buildArgs: imageDefinedInProvider.buildArgs || defaultBuildArgs,
24742485
cacheFrom: imageDefinedInProvider.cacheFrom || defaultCacheFrom,
24752486
platform: imageDefinedInProvider.platform || defaultPlatform,
2487+
provenance: imageDefinedInProvider.provenance || defaultProvenance,
24762488
scanOnPush: imageScanDefinedInProvider,
24772489
});
24782490
},

0 commit comments

Comments
 (0)