Skip to content

Commit

Permalink
Merge branch 'main' into conroy/snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jun 8, 2022
2 parents f93c6e9 + 5696c5d commit 3d5ad25
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The following tools need to be installed on your system prior to installing the
- [Node.js >= 14.15.0](https://nodejs.org/download/release/latest-v14.x/)
- We recommend using a version in [Active LTS](https://nodejs.org/en/about/releases/)
- [Yarn >= 1.19.1, < 2](https://yarnpkg.com/lang/en/docs/install)
- [.NET Core SDK 3.1.x](https://www.microsoft.com/net/download)
- [.NET Core SDK >= 3.1.x](https://www.microsoft.com/net/download)
- [Python >= 3.6.5, < 4.0](https://www.python.org/downloads/release/python-365/)
- [Docker >= 19.03](https://docs.docker.com/get-docker/)
- the Docker daemon must also be running
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ export class Function extends FunctionBase {
* aliasName: 'Live',
* version: fn.currentVersion,
* });
* ```
*
* @param aliasName The name of the alias
* @param options Alias options
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-rds/lib/cluster-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ export class AuroraMysqlEngineVersion {
public static readonly VER_2_10_2 = AuroraMysqlEngineVersion.builtIn_5_7('2.10.2');
/** Version "8.0.mysql_aurora.3.01.0". */
public static readonly VER_3_01_0 = AuroraMysqlEngineVersion.builtIn_8_0('3.01.0');
/** Version "8.0.mysql_aurora.3.01.1". */
public static readonly VER_3_01_1 = AuroraMysqlEngineVersion.builtIn_8_0('3.01.1');
/** Version "8.0.mysql_aurora.3.02.0". */
public static readonly VER_3_02_0 = AuroraMysqlEngineVersion.builtIn_8_0('3.02.0');

/**
* Create a new AuroraMysqlEngineVersion with an arbitrary version.
Expand Down
10 changes: 10 additions & 0 deletions packages/@aws-cdk/core/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export class DockerImage extends BundlingDockerImage {
'build', '-t', tag,
...(options.file ? ['-f', join(path, options.file)] : []),
...(options.platform ? ['--platform', options.platform] : []),
...(options.targetStage ? ['--target', options.targetStage] : []),
...flatten(Object.entries(buildArgs).map(([k, v]) => ['--build-arg', `${k}=${v}`])),
path,
];
Expand Down Expand Up @@ -487,6 +488,15 @@ export interface DockerBuildOptions {
* @default - no platform specified
*/
readonly platform?: string;

/**
* Set build target for multi-stage container builds. Any stage defined afterwards will be ignored.
*
* Example value: `build-env`
*
* @default - Build all stages defined in the Dockerfile
*/
readonly targetStage?: string;
}

function flatten(x: string[][]) {
Expand Down
40 changes: 39 additions & 1 deletion packages/@aws-cdk/core/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('bundling', () => {
fingerprintStub.callsFake(() => imageHash);
const platform = 'linux/someArch99';

const image = DockerImage.fromBuild('docker-path', { platform });
const image = DockerImage.fromBuild('docker-path', { platform: platform });
image.run();

const tagHash = crypto.createHash('sha256').update(JSON.stringify({
Expand All @@ -122,6 +122,44 @@ describe('bundling', () => {
])).toEqual(true);
});

test('bundling with image from asset with target stage', () => {
const spawnSyncStub = sinon.stub(child_process, 'spawnSync').returns({
status: 0,
stderr: Buffer.from('stderr'),
stdout: Buffer.from('stdout'),
pid: 123,
output: ['stdout', 'stderr'],
signal: null,
});

const imageHash = '123456abcdef';
const fingerprintStub = sinon.stub(FileSystem, 'fingerprint');
fingerprintStub.callsFake(() => imageHash);
const targetStage = 'i-love-testing';

const image = DockerImage.fromBuild('docker-path', { targetStage: targetStage });
image.run();

const tagHash = crypto.createHash('sha256').update(JSON.stringify({
path: 'docker-path',
targetStage,
})).digest('hex');
const tag = `cdk-${tagHash}`;

expect(spawnSyncStub.firstCall.calledWith('docker', [
'build', '-t', tag,
'--target', targetStage,
'docker-path',
])).toEqual(true);

expect(spawnSyncStub.secondCall.calledWith('docker', [
'run', '--rm',
tag,
])).toEqual(true);

});


test('throws in case of spawnSync error', () => {
sinon.stub(child_process, 'spawnSync').returns({
status: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class CdkToolkit {
}

if (!process.stdout.isTTY && !options.resourceMappingFile) {
throw new Error('--resource-mapping-file is required when input is not a terminal');
throw new Error('--resource-mapping is required when input is not a terminal');
}

const stack = stacks.stackArtifacts[0];
Expand Down

0 comments on commit 3d5ad25

Please sign in to comment.