Skip to content

Commit

Permalink
Changed Stage to return VersionQuery using only release version
Browse files Browse the repository at this point in the history
  • Loading branch information
horsmand committed Nov 5, 2020
1 parent c634e09 commit 7ffdb05
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
12 changes: 11 additions & 1 deletion packages/aws-rfdk/lib/deadline/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ export class Stage {
* @param id The construct ID
*/
public getVersion(scope: Construct, id: string): IVersion {
return new VersionQuery(scope, id, { version: this.manifest.version });
const releaseVersion = this.getReleaseVersion(this.manifest.version);
return new VersionQuery(scope, id, { version: releaseVersion });
}

/**
Expand All @@ -218,4 +219,13 @@ export class Stage {
...recipe,
});
}

/**
* This removes the patch version from a full version string. No validation is done as that is handled
* in the constructor with the version check.
*/
private getReleaseVersion(fullVersion: string): string {
const versionComponents = fullVersion.split('.');
return `${versionComponents[0]}.${versionComponents[1]}.${versionComponents[2]}`;
}
}
8 changes: 6 additions & 2 deletions packages/aws-rfdk/lib/deadline/test/stage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import * as path from 'path';

import {
expect as expectCDK,
haveResource,
haveResourceLike,
stringLike,
} from '@aws-cdk/assert';
import {
App,
Expand Down Expand Up @@ -400,7 +401,10 @@ describe('Stage', () => {

// WHEN
stage.getVersion(stack, 'Version');
expectCDK(stack).to(haveResource('Custom::RFDK_DEADLINE_INSTALLERS'));
expectCDK(stack).to(haveResourceLike('Custom::RFDK_DEADLINE_INSTALLERS', {
forceRun: stringLike('*'),
versionString: '10.1.9',
}));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as path from 'path';
import {
expect as expectCDK,
haveResourceLike,
stringLike,
} from '@aws-cdk/assert';
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
import {
Expand Down Expand Up @@ -57,7 +58,8 @@ describe('ThinkboxDockerRecipes', () => {
const MINOR_VERSION = 1;
const RELEASE_VERSION = 9;
const PATCH_VERSION = 2;
const FULL_VERSION_STRING = `${MAJOR_VERSION}.${MINOR_VERSION}.${RELEASE_VERSION}.${PATCH_VERSION}`;
const RELEASE_VERSION_STRING = `${MAJOR_VERSION}.${MINOR_VERSION}.${RELEASE_VERSION}`;
const FULL_VERSION_STRING = `${RELEASE_VERSION_STRING}.${PATCH_VERSION}`;

beforeEach(() => {
app = new App();
Expand Down Expand Up @@ -139,7 +141,8 @@ describe('ThinkboxDockerRecipes', () => {
});

expectCDK(stack).to(haveResourceLike('Custom::RFDK_DEADLINE_INSTALLERS', {
versionString: FULL_VERSION_STRING,
forceRun: stringLike('*'),
versionString: RELEASE_VERSION_STRING,
}));
});

Expand Down

0 comments on commit 7ffdb05

Please sign in to comment.