From 7176a5d5208da7d727bbf5112bc12533983380ea Mon Sep 17 00:00:00 2001 From: Niranjan Jayakar Date: Mon, 29 Mar 2021 17:01:30 +0100 Subject: [PATCH] fix(core): BundlingDockerImage.fromAsset() does not return a BundlingDockerImage (#13846) A previous change missed to fix the 'return' statement on this method. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/core/lib/bundling.ts | 4 ++-- packages/@aws-cdk/core/test/bundling.test.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/core/lib/bundling.ts b/packages/@aws-cdk/core/lib/bundling.ts index 5b4a579caf8f1..bd9299a5a990d 100644 --- a/packages/@aws-cdk/core/lib/bundling.ts +++ b/packages/@aws-cdk/core/lib/bundling.ts @@ -157,8 +157,8 @@ export class BundlingDockerImage { * * @deprecated use DockerImage.fromBuild() */ - public static fromAsset(path: string, options: DockerBuildOptions = {}) { - DockerImage.fromBuild(path, options) as BundlingDockerImage; + public static fromAsset(path: string, options: DockerBuildOptions = {}): BundlingDockerImage { + return DockerImage.fromBuild(path, options); } /** @param image The Docker image */ diff --git a/packages/@aws-cdk/core/test/bundling.test.ts b/packages/@aws-cdk/core/test/bundling.test.ts index 1c909142b3127..97b9d5969c2b3 100644 --- a/packages/@aws-cdk/core/test/bundling.test.ts +++ b/packages/@aws-cdk/core/test/bundling.test.ts @@ -173,6 +173,25 @@ nodeunitShim({ test.done(); }, + 'fromAsset'(test: Test) { + sinon.stub(child_process, 'spawnSync').returns({ + status: 0, + stderr: Buffer.from('stderr'), + stdout: Buffer.from('sha256:1234567890abcdef'), + pid: 123, + output: ['stdout', 'stderr'], + signal: null, + }); + + const imagePath = path.join(__dirname, 'fs/fixtures/test1'); + const image = BundlingDockerImage.fromAsset(imagePath, { + file: 'my-dockerfile', + }); + test.ok(image); + test.ok(image.image); + test.done(); + }, + 'custom entrypoint is passed through to docker exec'(test: Test) { const spawnSyncStub = sinon.stub(child_process, 'spawnSync').returns({ status: 0,