-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(assets): API cleanups (#2910)
Reorganize asset-related modules as follows: - @aws-cdk/assets: core types related to assets such as filesystem operations and staging - @aws-cdk/aws-s3-assets: file assets deployed to s3 - @aws-cdk/aws-ecr-assets: docker assets deployed to ecr - @aws-cdk/assets-docker: deprecated BREAKING CHANGE: `AssetProps.packaging` has been removed and is now automatically discovered based on the file type. * **assets:** `ZipDirectoryAsset` has been removed, use `aws-s3-assets.Asset`. * **assets:** `FileAsset` has been removed, use `aws-s3-assets.Asset`. * **lambda:** `Code.directory` and `Code.file` have been removed. Use `Code.asset`. * **assets-docker:** The module has been renamed to **aws-ecr-assets**
- Loading branch information
Elad Ben-Israel
authored
Jun 19, 2019
1 parent
1aa0589
commit 83eee09
Showing
65 changed files
with
1,209 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './image-asset'; | ||
// tslint:disable-next-line:no-console | ||
console.error('the @aws-cdk/assets-docker is deprecated. use @aws-cdk/aws-ecr-assets'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Common interface for all assets. | ||
*/ | ||
export interface IAsset { | ||
/** | ||
* A hash of the source of this asset, which is available at construction time. As this is a plain | ||
* string, it can be used in construct IDs in order to enforce creation of a new resource when | ||
* the content hash has changed. | ||
*/ | ||
readonly sourceHash: string; | ||
|
||
/** | ||
* A hash of the bundle for of this asset, which is only available at deployment time. As this is | ||
* a late-bound token, it may not be used in construct IDs, but can be passed as a resource | ||
* property in order to force a change on a resource when an asset is effectively updated. This is | ||
* more reliable than `sourceHash` in particular for assets which bundling phase involve external | ||
* resources that can change over time (such as Docker image builds). | ||
*/ | ||
readonly artifactHash: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './asset'; | ||
export * from './fs/copy-options'; | ||
export * from './fs/follow-mode'; | ||
export * from './staging'; | ||
export * from './api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { App, Stack } from '@aws-cdk/cdk'; | ||
import cxapi = require('@aws-cdk/cx-api'); | ||
import fs = require('fs'); | ||
import { Test } from 'nodeunit'; | ||
import path = require('path'); | ||
import { Staging } from '../lib'; | ||
|
||
export = { | ||
'base case'(test: Test) { | ||
// GIVEN | ||
const stack = new Stack(); | ||
const sourcePath = path.join(__dirname, 'fs', 'fixtures', 'test1'); | ||
|
||
// WHEN | ||
const staging = new Staging(stack, 's1', { sourcePath }); | ||
|
||
test.deepEqual(staging.sourceHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00'); | ||
test.deepEqual(staging.sourcePath, sourcePath); | ||
test.deepEqual(stack.resolve(staging.stagedPath), 'asset.2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00'); | ||
test.done(); | ||
}, | ||
|
||
'staging can be disabled through context'(test: Test) { | ||
// GIVEN | ||
const stack = new Stack(); | ||
stack.node.setContext(cxapi.DISABLE_ASSET_STAGING_CONTEXT, true); | ||
const sourcePath = path.join(__dirname, 'fs', 'fixtures', 'test1'); | ||
|
||
// WHEN | ||
const staging = new Staging(stack, 's1', { sourcePath }); | ||
|
||
test.deepEqual(staging.sourceHash, '2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00'); | ||
test.deepEqual(staging.sourcePath, sourcePath); | ||
test.deepEqual(stack.resolve(staging.stagedPath), sourcePath); | ||
test.done(); | ||
}, | ||
|
||
'files are copied to the output directory during synth'(test: Test) { | ||
// GIVEN | ||
const app = new App(); | ||
const stack = new Stack(app, 'stack'); | ||
const directory = path.join(__dirname, 'fs', 'fixtures', 'test1'); | ||
const file = path.join(__dirname, 'fs', 'fixtures.tar.gz'); | ||
|
||
// WHEN | ||
new Staging(stack, 's1', { sourcePath: directory }); | ||
new Staging(stack, 'file', { sourcePath: file }); | ||
|
||
// THEN | ||
const assembly = app.synth(); | ||
test.deepEqual(fs.readdirSync(assembly.directory), [ | ||
'asset.2f37f937c51e2c191af66acf9b09f548926008ec68c575bd2ee54b6e997c0e00', | ||
'asset.af10ac04b3b607b0f8659c8f0cee8c343025ee75baf0b146f10f0e5311d2c46b.gz', | ||
'cdk.out', | ||
'manifest.json', | ||
'stack.template.json' | ||
]); | ||
test.done(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.js | ||
*.js.map | ||
*.d.ts | ||
node_modules | ||
dist | ||
tsconfig.json | ||
tslint.json | ||
|
||
.LAST_BUILD | ||
.nyc_output | ||
coverage | ||
|
||
.jsii | ||
|
||
.nycrc | ||
.LAST_PACKAGE | ||
*.snk |
Oops, something went wrong.