-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aws-cdk): support fixed repository name for DockerImageAsset (#2032
) Add a `repositoryName` argument to `DockerImageAsset` to control the name of the repository that the image gets uploaded to. This makes it easier to reference Docker Images created and deployed by CDK from EKS (Kubernetes) YAML resource files.
- Loading branch information
1 parent
133dc98
commit 942f938
Showing
6 changed files
with
96 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
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,54 @@ | ||
import cxapi = require('@aws-cdk/cx-api'); | ||
import { Test } from 'nodeunit'; | ||
import { ToolkitInfo } from '../lib'; | ||
import { prepareContainerAsset } from '../lib/docker'; | ||
import { MockSDK } from './util/mock-sdk'; | ||
|
||
export = { | ||
async 'creates repository with given name'(test: Test) { | ||
// GIVEN | ||
|
||
let createdName; | ||
|
||
const sdk = new MockSDK(); | ||
sdk.stubEcr({ | ||
describeRepositories() { | ||
return { repositories: [] }; | ||
}, | ||
|
||
createRepository(req) { | ||
createdName = req.repositoryName; | ||
|
||
// Stop the test so that we don't actually docker build | ||
throw new Error('STOPTEST'); | ||
}, | ||
}); | ||
|
||
const toolkit = new ToolkitInfo({ | ||
sdk, | ||
bucketName: 'BUCKET_NAME', | ||
bucketEndpoint: 'BUCKET_ENDPOINT', | ||
environment: { name: 'env', account: '1234', region: 'abc' } | ||
}); | ||
|
||
// WHEN | ||
const asset: cxapi.ContainerImageAssetMetadataEntry = { | ||
id: 'assetId', | ||
imageNameParameter: 'MyParameter', | ||
packaging: 'container-image', | ||
path: '/foo', | ||
repositoryName: 'some-name', | ||
}; | ||
|
||
try { | ||
await prepareContainerAsset(asset, toolkit, false); | ||
} catch (e) { | ||
if (!/STOPTEST/.test(e.toString())) { throw e; } | ||
} | ||
|
||
// THEN | ||
test.deepEqual(createdName, 'some-name'); | ||
|
||
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