Add image tag dropdown for publish to docker in ADS (#21029)

* add image tag dropdown to publish dialog

* cleanup

* add filtering and move default tag to the first in the dropdown

* fix test
This commit is contained in:
Kim Santiago
2022-10-31 18:02:03 -07:00
committed by GitHub
parent 0ac83852c7
commit bd7d44ad31
3 changed files with 53 additions and 21 deletions

View File

@@ -53,9 +53,10 @@ export function getDockerImagePlaceHolder(target: string): string {
* Returns the list of image tags for given target
* @param imageInfo docker image info
* @param target project target version
* @param defaultTagFirst whether the default tag should be the first entry in the array
* @returns image tags
*/
export async function getImageTags(imageInfo: DockerImageInfo, target: string): Promise<string[]> {
export async function getImageTags(imageInfo: DockerImageInfo, target: string, defaultTagFirst?: boolean): Promise<string[]> {
let imageTags: string[] | undefined = [];
const versionToImageTags: Map<number, string[]> = new Map<number, string[]>();
@@ -87,6 +88,14 @@ export async function getImageTags(imageInfo: DockerImageInfo, target: string):
imageTags = imageTags ?? [];
imageTags = imageTags.sort((a, b) => a.indexOf(constants.dockerImageDefaultTag) > 0 ? -1 : a.localeCompare(b));
if (defaultTagFirst) {
const defaultIndex = imageTags.findIndex(i => i === imageInfo.defaultTag);
if (defaultIndex > -1) {
imageTags.splice(defaultIndex, 1);
imageTags.unshift(imageInfo.defaultTag);
}
}
}
} catch (err) {
// Ignore the error. If http request fails, we just use the default tag