@@ -5,18 +5,7 @@ import * as fs from 'fs-extra';
55import * as sinon from 'sinon' ;
66import { FileAssetPackaging } from '../../cloud-assembly-schema' ;
77import * as cxapi from '../../cx-api' ;
8- import {
9- App ,
10- AssetHashType ,
11- AssetStaging ,
12- BundlingFileAccess ,
13- BundlingOptions ,
14- BundlingOutput ,
15- DockerImage ,
16- FileSystem ,
17- Stack ,
18- Stage ,
19- } from '../lib' ;
8+ import { App , AssetHashType , AssetStaging , DockerImage , BundlingOptions , BundlingOutput , FileSystem , Stack , Stage , BundlingFileAccess } from '../lib' ;
209
2110const STUB_INPUT_FILE = '/tmp/docker-stub.input' ;
2211const STUB_INPUT_CONCAT_FILE = '/tmp/docker-stub.input.concat' ;
@@ -322,7 +311,7 @@ describe('staging', () => {
322311 const assembly = app . synth ( ) ;
323312 expect (
324313 readDockerStubInput ( ) ) . toEqual (
325- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
314+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
326315 ) ;
327316 expect ( fs . readdirSync ( assembly . directory ) ) . toEqual ( [
328317 'asset.b1e32e86b3523f2fa512eb99180ee2975a50a4439e63e8badd153f2a68d61aa4' ,
@@ -401,7 +390,7 @@ describe('staging', () => {
401390 // We're testing that docker was run exactly once even though there are two bundling assets.
402391 expect (
403392 readDockerStubInputConcat ( ) ) . toEqual (
404- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
393+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
405394 ) ;
406395
407396 expect ( fs . readdirSync ( assembly . directory ) ) . toEqual ( [
@@ -446,7 +435,7 @@ describe('staging', () => {
446435 // and that the hash is based on the output
447436 expect (
448437 readDockerStubInputConcat ( ) ) . toEqual (
449- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
438+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
450439 ) ;
451440
452441 expect ( fs . readdirSync ( assembly . directory ) ) . toEqual ( [
@@ -494,8 +483,8 @@ describe('staging', () => {
494483 // operating on the same source asset.
495484 expect (
496485 readDockerStubInputConcat ( ) ) . toEqual (
497- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS\n' +
498- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated --env UNIQUE_ENV_VAR=SOMEVALUE -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
486+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS\n` +
487+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated --env UNIQUE_ENV_VAR=SOMEVALUE -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
499488 ) ;
500489
501490 expect ( fs . readdirSync ( assembly . directory ) ) . toEqual ( [
@@ -543,7 +532,7 @@ describe('staging', () => {
543532 // We're testing that docker was run once, only for the first Asset, since the only difference is the token.
544533 expect (
545534 readDockerStubInputConcat ( ) ) . toEqual (
546- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated --env PIP_INDEX_URL=https://aws:MY_SECRET_TOKEN@your-code-repo.d.codeartifact.us-west-2.amazonaws.com/pypi/python/simple/ -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
535+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated --env PIP_INDEX_URL=https://aws:MY_SECRET_TOKEN@your-code-repo.d.codeartifact.us-west-2.amazonaws.com/pypi/python/simple/ -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
547536 ) ;
548537
549538 expect ( fs . readdirSync ( assembly . directory ) ) . toEqual ( [
@@ -674,7 +663,7 @@ describe('staging', () => {
674663
675664 expect (
676665 readDockerStubInputConcat ( ) ) . toEqual (
677- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
666+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
678667 ) ;
679668
680669 expect ( appAssembly . directory ) . toEqual ( app2Assembly . directory ) ;
@@ -736,7 +725,7 @@ describe('staging', () => {
736725
737726 expect (
738727 readDockerStubInputConcat ( ) ) . toEqual (
739- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated --env PIP_EXTRA_INDEX_URL=https://aws:MY_SECRET_TOKEN@your-code-repo.d.codeartifact.us-west-2.amazonaws.com/pypi/python/simple/ -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
728+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated --env PIP_EXTRA_INDEX_URL=https://aws:MY_SECRET_TOKEN@your-code-repo.d.codeartifact.us-west-2.amazonaws.com/pypi/python/simple/ -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
740729 ) ;
741730
742731 expect ( appAssembly . directory ) . toEqual ( app2Assembly . directory ) ;
@@ -766,7 +755,7 @@ describe('staging', () => {
766755
767756 expect (
768757 readDockerStubInput ( ) ) . toEqual (
769- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS_NO_OUTPUT' ,
758+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS_NO_OUTPUT` ,
770759 ) ;
771760 } ) ;
772761
@@ -789,7 +778,7 @@ describe('staging', () => {
789778 // THEN
790779 expect (
791780 readDockerStubInput ( ) ) . toEqual (
792- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
781+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
793782 ) ;
794783 expect ( asset . assetHash ) . toEqual ( '33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f' ) ;
795784 } ) ;
@@ -814,7 +803,7 @@ describe('staging', () => {
814803 // THEN
815804 expect (
816805 readDockerStubInput ( ) ) . toEqual (
817- ' run --rm --security-opt no-new-privileges -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
806+ ` run --rm --security-opt no-new-privileges ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
818807 ) ;
819808 expect ( asset . assetHash ) . toEqual ( '33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f' ) ;
820809 } ) ;
@@ -839,7 +828,7 @@ describe('staging', () => {
839828 // THEN
840829 expect (
841830 readDockerStubInput ( ) ) . toEqual (
842- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input --entrypoint DOCKER_STUB_SUCCESS alpine DOCKER_STUB_SUCCESS' ,
831+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input --entrypoint DOCKER_STUB_SUCCESS alpine DOCKER_STUB_SUCCESS` ,
843832 ) ;
844833 expect ( asset . assetHash ) . toEqual ( '33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f' ) ;
845834 } ) ;
@@ -957,7 +946,7 @@ describe('staging', () => {
957946 } ) ) . toThrow ( / F a i l e d t o b u n d l e a s s e t s t a c k \/ A s s e t / ) ;
958947 expect (
959948 readDockerStubInput ( ) ) . toEqual (
960- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input this-is-an-invalid-docker-image DOCKER_STUB_FAIL' ,
949+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input this-is-an-invalid-docker-image DOCKER_STUB_FAIL` ,
961950 ) ;
962951 } ) ;
963952
@@ -1248,7 +1237,7 @@ describe('staging', () => {
12481237
12491238 expect (
12501239 readDockerStubInput ( ) ) . toEqual (
1251- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
1240+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
12521241 ) ;
12531242 expect ( asset . assetHash ) . toEqual ( '33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f' ) ; // hash of MyStack/Asset
12541243 } ) ;
@@ -1272,7 +1261,7 @@ describe('staging', () => {
12721261
12731262 expect (
12741263 readDockerStubInput ( ) ) . toEqual (
1275- ' run --rm -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS' ,
1264+ ` run --rm ${ USER_ARG } -v /input:/asset-input:delegated -v /output:/asset-output:delegated -w /asset-input alpine DOCKER_STUB_SUCCESS` ,
12761265 ) ;
12771266 expect ( asset . assetHash ) . toEqual ( '33cbf2cae5432438e0f046bc45ba8c3cef7b6afcf47b59d1c183775c1918fb1f' ) ; // hash of MyStack/Asset
12781267 } ) ;
@@ -1656,11 +1645,12 @@ describe('staging with docker cp', () => {
16561645
16571646// Reads a docker stub and cleans the volume paths out of the stub.
16581647function readAndCleanDockerStubInput ( file : string ) {
1659- return fs
1660- . readFileSync ( file , 'utf-8' )
1648+ const commands = fs
1649+ . readFileSync ( file , 'utf-8' ) ;
1650+ return commands
16611651 . trim ( )
1662- . replace ( / - v ( [ ^ : ] + ) : \/ a s s e t - i n p u t / g, '-v /input:/asset-input' )
1663- . replace ( / - v ( [ ^ : ] + ) : \/ a s s e t - o u t p u t / g, '-v /output:/asset-output' ) ;
1652+ . replace ( / - v ( [ ^ : \n ] + ) : \/ a s s e t - i n p u t / g, '-v /input:/asset-input' )
1653+ . replace ( / - v ( [ ^ : \n ] + ) : \/ a s s e t - o u t p u t / g, '-v /output:/asset-output' ) ;
16641654}
16651655
16661656// Last docker input since last teardown
0 commit comments