Skip to content

Commit

Permalink
fix(core): BundlingDockerImage.fromAsset() does not return a Bundling…
Browse files Browse the repository at this point in the history
…DockerImage (#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*
  • Loading branch information
Niranjan Jayakar authored Mar 29, 2021
1 parent 8fb30ea commit 7176a5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/core/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
19 changes: 19 additions & 0 deletions packages/@aws-cdk/core/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7176a5d

Please sign in to comment.