mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
SQL Project Deploy to docker container - Adding a UI for user to select docker image tag (#19297)
This commit is contained in:
@@ -641,3 +641,47 @@ export function getWellKnownDatabaseSources(databaseSourceValues: string[]): str
|
||||
|
||||
return Array.from(databaseSourceSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns SQL version number from docker image name which is in the beginning of the image name
|
||||
* @param imageName docker image name
|
||||
* @returns SQL server version
|
||||
*/
|
||||
export function findSqlVersionInImageName(imageName: string): number | undefined {
|
||||
|
||||
// Regex to find the version in the beginning of the image name
|
||||
// e.g. 2017-CU16-ubuntu, 2019-latest
|
||||
const regex = new RegExp('^([0-9]+)[-].+$');
|
||||
|
||||
if (regex.test(imageName)) {
|
||||
const finds = regex.exec(imageName);
|
||||
if (finds) {
|
||||
|
||||
// 0 is the full match and 1 is the number with pattern inside the first ()
|
||||
return +finds[1];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns SQL version number from target platform name
|
||||
* @param targetPlatform target platform
|
||||
* @returns SQL server version
|
||||
*/
|
||||
export function findSqlVersionInTargetPlatform(targetPlatform: string): number | undefined {
|
||||
|
||||
// Regex to find the version in target platform
|
||||
// e.g. SQL Server 2019
|
||||
const regex = new RegExp('([0-9]+)$');
|
||||
|
||||
if (regex.test(targetPlatform)) {
|
||||
const finds = regex.exec(targetPlatform);
|
||||
if (finds) {
|
||||
|
||||
// 0 is the full match and 1 is the number with pattern inside the first ()
|
||||
return +finds[1];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user