SQL Project Deploy to docker container - Adding a UI for user to select docker image tag (#19297)

This commit is contained in:
Leila Lali
2022-05-11 11:29:11 -07:00
committed by GitHub
parent 65ef41d53d
commit e10b1eb5a9
10 changed files with 301 additions and 30 deletions

View File

@@ -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;
}