forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(assets): docker asset versions are pushed to separate repositories (
aws#4537) * fix(core): upload ecr assets to separate repositories Derive repository name from asset id, not asset source hash. We need to derive the repository name from the asset id otherwise the CDK will create a new repository each time the image changes (which will make layer caching useless). Fixes aws#4535 * move default for repositoryName to DockerImageAsset * repositoryName * add test * allow breaking change for addDockerImageAsset * non breaking * add test for addDockerImageAsset * more tests * remove useless diff * simplify * test.assets.ts
- Loading branch information
1 parent
406dc8e
commit 8484114
Showing
6 changed files
with
152 additions
and
6 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
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,77 @@ | ||
import cxapi = require('@aws-cdk/cx-api'); | ||
import { Test } from 'nodeunit'; | ||
import { FileAssetPackaging, Stack } from '../lib'; | ||
import { toCloudFormation } from './util'; | ||
|
||
export = { | ||
'addFileAsset correctly sets metadata and creates S3 parameters'(test: Test) { | ||
// GIVEN | ||
const stack = new Stack(); | ||
|
||
// WHEN | ||
stack.addFileAsset({ | ||
fileName: 'file-name', | ||
packaging: FileAssetPackaging.ZIP_DIRECTORY, | ||
sourceHash: 'source-hash' | ||
}); | ||
|
||
// THEN | ||
const assetMetadata = stack.node.metadata.find(({ type }) => type === cxapi.ASSET_METADATA); | ||
|
||
test.equal(assetMetadata && assetMetadata.data.path, 'file-name'); | ||
test.equal(assetMetadata && assetMetadata.data.id, 'source-hash'); | ||
test.equal(assetMetadata && assetMetadata.data.packaging, FileAssetPackaging.ZIP_DIRECTORY); | ||
test.equal(assetMetadata && assetMetadata.data.sourceHash, 'source-hash'); | ||
|
||
test.deepEqual(toCloudFormation(stack), { | ||
Parameters: { | ||
AssetParameterssourcehashS3BucketE6E91E3E: { | ||
Type: 'String', | ||
Description: 'S3 bucket for asset "source-hash"' | ||
}, | ||
AssetParameterssourcehashS3VersionKeyAC4157C3: { | ||
Type: 'String', | ||
Description: 'S3 key for asset version "source-hash"' | ||
}, | ||
AssetParameterssourcehashArtifactHashADBAE418: { | ||
Type: 'String', | ||
Description: 'Artifact hash for asset "source-hash"' | ||
} | ||
} | ||
}); | ||
|
||
test.done(); | ||
|
||
}, | ||
|
||
'addDockerImageAsset correctly sets metadata and creates an ECR parameter'(test: Test) { | ||
// GIVEN | ||
const stack = new Stack(); | ||
|
||
// WHEN | ||
stack.addDockerImageAsset({ | ||
sourceHash: 'source-hash', | ||
directoryName: 'directory-name', | ||
repositoryName: 'repository-name' | ||
}); | ||
|
||
// THEN | ||
const assetMetadata = stack.node.metadata.find(({ type }) => type === cxapi.ASSET_METADATA); | ||
|
||
test.equal(assetMetadata && assetMetadata.data.packaging, 'container-image'); | ||
test.equal(assetMetadata && assetMetadata.data.path, 'directory-name'); | ||
test.equal(assetMetadata && assetMetadata.data.sourceHash, 'source-hash'); | ||
test.equal(assetMetadata && assetMetadata.data.repositoryName, 'repository-name'); | ||
|
||
test.deepEqual(toCloudFormation(stack), { | ||
Parameters: { | ||
AssetParameterssourcehashImageName3B572B12: { | ||
Type: 'String', | ||
Description: 'ECR repository name and tag for asset "source-hash"' | ||
} | ||
} | ||
}); | ||
|
||
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