Skip to content

Commit

Permalink
Merge branch 'feature/python-39-support-for-python-shell' of github.c…
Browse files Browse the repository at this point in the history
…om:meve/aws-cdk into feature/python-39-support-for-python-shell
  • Loading branch information
meve committed Aug 19, 2022
2 parents fafdd00 + 0668c8a commit 3a89d40
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.v2.alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.38.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.38.0-alpha.0...v2.38.1-alpha.0) (2022-08-18)

## [2.38.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.37.1-alpha.0...v2.38.0-alpha.0) (2022-08-17)


Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.38.1](https://github.com/aws/aws-cdk/compare/v2.38.0...v2.38.1) (2022-08-18)

### Reverts

* cli: revert "feat(cli): --concurrency option" ([#21664](https://github.com/aws/aws-cdk/pull/21664)) ([2ad2163b](https://github.com/aws/aws-cdk/commit/2ad2163b96254f9715dff405100a047d6c2c5958))
* cli: revert "feat(cli): cdk watch --concurrency" ([#21665](https://github.com/aws/aws-cdk/pull/21665)) ([6048d4fc](https://github.com/aws/aws-cdk/commit/6048d4fc37239bcd5193d5487464590c786bf56b))

## [2.38.0](https://github.com/aws/aws-cdk/compare/v2.37.1...v2.38.0) (2022-08-17)


Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-ecr-assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ configure it on the asset itself.
Use `asset.imageUri` to reference the image. It includes both the ECR image URL
and tag.

Use `asset.imageTag` to reference only the image tag.

You can optionally pass build args to the `docker build` command by specifying
the `buildArgs` property. It is recommended to skip hashing of `buildArgs` for
values that can change between different machines to maintain a consistent
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-ecr-assets/lib/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ export class DockerImageAsset extends Construct implements IAsset {
*/
public readonly assetHash: string;

/**
* The tag of this asset when it is uploaded to ECR. The tag may differ from the assetHash if a stack synthesizer adds a dockerTagPrefix.
*/
public readonly imageTag: string;

/**
* The path to the asset, relative to the current Cloud Assembly
*
Expand Down Expand Up @@ -362,6 +367,7 @@ export class DockerImageAsset extends Construct implements IAsset {

this.repository = ecr.Repository.fromRepositoryName(this, 'Repository', location.repositoryName);
this.imageUri = location.imageUri;
this.imageTag = location.imageTag ?? this.assetHash;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-ecr-assets/lib/tarball-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ export class TarballImageAsset extends Construct implements IAsset {
*/
public readonly assetHash: string;

/**
* The tag of this asset when it is uploaded to ECR. The tag may differ from the assetHash if a stack synthesizer adds a dockerTagPrefix.
*/
public readonly imageTag: string;

constructor(scope: Construct, id: string, props: TarballImageAssetProps) {
super(scope, id);

Expand Down Expand Up @@ -78,6 +83,7 @@ export class TarballImageAsset extends Construct implements IAsset {

this.repository = ecr.Repository.fromRepositoryName(this, 'Repository', location.repositoryName);
this.imageUri = location.imageUri;
this.imageTag = location.imageTag ?? this.assetHash;
}
}

24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-ecr-assets/test/image-asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,30 @@ describe('image asset', () => {
expect(asset1.assetHash).toEqual('13248c55633f3b198a628bb2ea4663cb5226f8b2801051bd0c725950266fd590');
expect(asset2.assetHash).toEqual('b78978ca702a8eccd37804ce31d76cd83a695b557dbf95aeb109332ee8b1fd32');
});

describe('imageTag is correct for different stack synthesizers', () => {
const stack1 = new Stack();
const stack2 = new Stack(undefined, undefined, {
synthesizer: new DefaultStackSynthesizer({
dockerTagPrefix: 'banana',
}),
});

const directory = path.join(__dirname, 'demo-image-custom-docker-file');

const asset1 = new DockerImageAsset(stack1, 'Asset1', { directory });
const asset2 = new DockerImageAsset(stack2, 'Asset2', { directory });

test('stack with default synthesizer', () => {
expect(asset1.assetHash).toEqual('13248c55633f3b198a628bb2ea4663cb5226f8b2801051bd0c725950266fd590');
expect(asset1.imageTag).toEqual('13248c55633f3b198a628bb2ea4663cb5226f8b2801051bd0c725950266fd590');
});

test('stack with overwritten synthesizer', () => {
expect(asset2.assetHash).toEqual('13248c55633f3b198a628bb2ea4663cb5226f8b2801051bd0c725950266fd590');
expect(asset2.imageTag).toEqual('banana13248c55633f3b198a628bb2ea4663cb5226f8b2801051bd0c725950266fd590');
});
});
});

function testDockerDirectoryIsStagedWithoutFilesSpecifiedInDockerignore(app: App, ignoreMode?: IgnoreMode) {
Expand Down
28 changes: 27 additions & 1 deletion packages/@aws-cdk/aws-ecr-assets/test/tarball-asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Template } from '@aws-cdk/assertions';
import * as iam from '@aws-cdk/aws-iam';
import { testFutureBehavior } from '@aws-cdk/cdk-build-tools/lib/feature-flag';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import { App, Stack } from '@aws-cdk/core';
import { App, Stack, DefaultStackSynthesizer } from '@aws-cdk/core';
import * as cxapi from '@aws-cdk/cx-api';
import { TarballImageAsset } from '../lib';

Expand Down Expand Up @@ -136,6 +136,32 @@ describe('image asset', () => {
}).toThrow(/Cannot find file at/);

});

describe('imageTag is correct for different stack synthesizers', () => {
const stack1 = new Stack();
const stack2 = new Stack(undefined, undefined, {
synthesizer: new DefaultStackSynthesizer({
dockerTagPrefix: 'banana',
}),
});
const asset1 = new TarballImageAsset(stack1, 'MyAsset', {
tarballFile: 'test/demo-tarball/empty.tar',
});
const asset2 = new TarballImageAsset(stack2, 'MyAsset', {
tarballFile: 'test/demo-tarball/empty.tar',
});

test('stack with default synthesizer', () => {
expect(asset1.assetHash).toEqual('95c924c84f5d023be4edee540cb2cb401a49f115d01ed403b288f6cb412771df');
expect(asset1.imageTag).toEqual('95c924c84f5d023be4edee540cb2cb401a49f115d01ed403b288f6cb412771df');
});

test('stack with overwritten synthesizer', () => {
expect(asset2.assetHash).toEqual('95c924c84f5d023be4edee540cb2cb401a49f115d01ed403b288f6cb412771df');
expect(asset2.imageTag).toEqual('banana95c924c84f5d023be4edee540cb2cb401a49f115d01ed403b288f6cb412771df');
});
});

});

function isAssetManifest(x: cxapi.CloudArtifact): x is cxapi.AssetManifestArtifact {
Expand Down
8 changes: 7 additions & 1 deletion packages/@aws-cdk/core/lib/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,18 @@ export interface FileAssetLocation {
*/
export interface DockerImageAssetLocation {
/**
* The URI of the image in Amazon ECR.
* The URI of the image in Amazon ECR (including a tag).
*/
readonly imageUri: string;

/**
* The name of the ECR repository.
*/
readonly repositoryName: string;

/**
* The tag of the image in Amazon ECR.
* @default - the hash of the asset, or the `dockerTagPrefix` concatenated with the asset hash if a `dockerTagPrefix` is specified in the stack synthesizer
*/
readonly imageTag?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class AssetManifestBuilder {
role?: RoleOptions,
): DockerImageAssetLocation {
validateDockerImageAssetSource(asset);
const imageTag = dockerTagPrefix + asset.sourceHash;
const imageTag = `${dockerTagPrefix}${asset.sourceHash}`;

// Add to manifest
this.dockerImages[asset.sourceHash] = {
Expand Down Expand Up @@ -114,6 +114,7 @@ export class AssetManifestBuilder {
imageUri: cfnify(
`${account}.dkr.ecr.${region}.${urlSuffix}/${repositoryName}:${imageTag}`,
),
imageTag: cfnify(imageTag),
};
}

Expand Down
4 changes: 2 additions & 2 deletions version.v2.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.38.0",
"alphaVersion": "2.38.0-alpha.0"
"version": "2.38.1",
"alphaVersion": "2.38.1-alpha.0"
}

0 comments on commit 3a89d40

Please sign in to comment.