-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Update stage-deadline script with new version index #139
Conversation
private implementsIVersionProviderProperties(value: any): boolean { | ||
if (!value || typeof(value) !== 'object') { return false; } | ||
|
||
// TODO: Ignore case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you either implement these TODO's or are you going to create issues to fix them.
const productionInfoURL = 'https://downloads.thinkboxsoftware.com/version_info.json'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const parsedUrl = require('url').parse(productionInfoURL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to use require imports here? or can we just do a normal import at the top of the file.
|
||
return new Promise((resolve, reject) => { | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
require('https').get(options, (res: IncomingMessage) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question for imports.
} | ||
|
||
/** | ||
* This method reads index file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring is not very useful since all it says is the name of the function.
What do we do with the read file return it ? throw it out? what do we return it as? a string? json blob?
} | ||
|
||
private parseVersionString(versionString: string): RegExpExecArray | null { | ||
const VALID_VERSION_REGEX = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this REGEX is constant could we make this a class level constant.
Also could we use /^(0|[1-9]\d*)(?:.(0|[1-9]\d*)){0,3}$/ instead. the {0,3} means 0-3 copies of the preceeding so we can use this instead of repeating the same section 3 times with the ? quantifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your expression work great for validation but it return only first and last part as result of exec
export async function handler(event: CfnRequestEvent, context: LambdaContext): Promise<string> { | ||
const versionProvider = new VersionProvider(); | ||
return await versionProvider.handler(event, context); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a new line at the end of the file.
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Outdated
Show resolved
Hide resolved
8906ad8
to
2359f29
Compare
Added the do not merge label because this is dependent on the version index file being made available on the downloads website first. |
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/test/version-provider.test.ts
Outdated
Show resolved
Hide resolved
e1a8396
to
002f8be
Compare
The index file has been published, I've removed the do not merge label. Everything looks good, approved. |
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Outdated
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Outdated
Show resolved
Hide resolved
// and get the matching version from the indexed version map. | ||
for (let versionIndex = 0; versionIndex < 4; versionIndex++) { | ||
let version: string; | ||
if (null === requestedVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be changed to using optional chaining something along the lines of
requestedVersion?.[versionIndex + 1] == null
002f8be
to
a5c4f2c
Compare
} | ||
|
||
/** | ||
* @inheritdoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inheritdoc from what? This is a base class
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Show resolved
Hide resolved
packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider.ts
Show resolved
Hide resolved
a5c4f2c
to
47b6a7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grant's comments are still unresolved, but I can see they've been addressed. Looks good to me!
* feat: add version-provider * feat: update stage-deadline script with new version index * fix: move version provider logic in separate script from handler Co-authored-by: Eugene Kozlov <kozlove@dev-dsk-kozlove-2b-2198d727.us-west-2.amazon.com>
Problem:
We need to update our stage-deadline script to use index file with installers URLs, so customers can specify a version, such as 10.1.9 or 10.1.9.2, or latest and not have to enter the URL's themselves, or have the script attempt to form them on its own. The updated script should access the index, parse the JSON, and use that to determine where to download the customer's requested version.
Solution
Testing
Were created unit tests for lambda script that covered 100% of functionality.
Was built project and tested that stage-script correctly download deadline client and Docker recipe in next cases:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license