-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathRegistryImageInputStep.ts
More file actions
41 lines (34 loc) · 1.98 KB
/
RegistryImageInputStep.ts
File metadata and controls
41 lines (34 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
import { acrDomain } from "../../../constants";
import { parseImageName } from "../../../utils/imageNameUtils";
import { localize } from "../../../utils/localize";
import { IContainerRegistryImageContext } from "./IContainerRegistryImageContext";
import { getLatestContainerAppImage } from "./getLatestContainerImage";
export class RegistryImageInputStep extends AzureWizardPromptStep<IContainerRegistryImageContext> {
public async prompt(context: IContainerRegistryImageContext): Promise<void> {
const prompt: string = localize('registryImagePrompt', 'Enter the container image with tag');
const placeHolder: string = localize('registryImagePlaceHolder', 'For example: `mcr.microsoft.com/azuredocs/containerapps-helloworld:latest`');
// Try to suggest an image name only when the user is deploying to a Container App
let value: string | undefined;
if (context.targetContainer) {
const { registryDomain, imageNameReference } = parseImageName(getLatestContainerAppImage(context.targetContainer));
// Only bother carrying over the suggestion if the old image was from a third party registry
if (registryDomain !== acrDomain) {
value = imageNameReference;
}
}
context.image = (await context.ui.showInputBox({
prompt,
placeHolder,
value
})).trim();
context.valuesToMask.push(context.image);
}
public shouldPrompt(context: IContainerRegistryImageContext): boolean {
return context.image === undefined;
}
}